It should be the string format and we are going to make the request using XMLHttpRequest and where to make a request, blnAsync asyou need to pass a boolean value true or also whether you are making a sync operation or not.Īnd finally, after we get the response, we are going to pass it and store it in a variable. 'spin wheels whilst waiting for response While objRequest.readyState 4Įnd With Set JsonObject = JsonConverter.ParseJson(strResponse) setRequestHeader "Authorization", "Bearer " & token setRequestHeader "Content-Type", "application/json" ĭim JsonObject As Object Dim objRequest As Object Dim strUrl As String Dim blnAsync As Boolean Dim strResponse As String Set objRequest = CreateObject( "MSXML2.XMLHTTP") So let me create a variable called strUrl. So let me create a variable called objRequest and the data type is the object and we need to store the endpoint URL in a string.
ACCESS API VBA CODE
So let write API calling code on button click of each button i.e GetUser and CreateUser and write code for calling the rest api. So here you can see Microsoft Scripting runtime, select and click on OK. So enable the Microsoft scripting runtime references that you can find it in the list scroll down. And now we are going to deal with a dictionary. So now go back to the Form and click on Tools and select references. You can see a new module here, so it imported all the scripts which are present on the Bas file. So this is the folder that I extracted go inside this folder and select the JsonConverter.bas And click on Open.
ACCESS API VBA DOWNLOAD
The first thing is we need to import the JSON converter that we download from Github. So before writing a script, we need to do some import. So now you can see the visual basic IDE and go to insert, and insert a form and add two button control on it.
so go to the developer tool and visual basic.
I have already created a blank Excel format.
ACCESS API VBA ZIP
So just click on the download code and it will be downloaded in the zip format.Īnd now go to your Excel sheet. So we are going to use VBA-tools JSON parser which helps us to parse the JSON that we receive after making a get request.Īnd we have to pass this JSON object as a parameter to this VBA JSON or method so that we can easily parse the object and get a value that we are looking for.
ACCESS API VBA HOW TO
How to call rest api from excel vba and parse json response return by rest ApiĪnd this is what we are going to use that in our script. If you make an API call with this get request, you will get on the dummy data user ID, email,first_name,last_name, image, etc.