Does anyone (@TimHall) have suggestions on how to make a GET JSON request to a webservice using VBA-WEB in MS Access with a cURL string? I have reviewed many samples including these: Equivalent cURL in VBA? ; Using Excel to pull data from API ; and more. The cURL is this:
curl -XGET -H "Authorization: Bearer [oauth_token]" -H "Content-Type: application/hal+json" https://api.somewebsite.com/api/my/orders/selling/all?updated_start_date=2015-01-01T12:00-00:00&updated_end_date=2015-01-02T12:00-00:00
My end goal is to "get" the json and then save it to a .txt file on a local drive for use with JsonConverter.ParseJson.
Per @QHall suggestion, here is my best attempt- revised, based on this : https://vba-tools.github.io/VBA-Web/docs/ "GetJSON" section.
Private Sub GetTheOrdersJson()
Dim Client As New WebClient
Dim Url As String
Url = "https://api.somewebsite.com/api/my/orders/selling/all"
Dim Response As WebResponse
Set Response = Client.GetJson(Url)
Dim Headers As New Collection
Headers.Add WebHelpers.CreateKeyValue("Authorization", "Bearer [1234567890]")
Dim Options As New Dictionary
Options.Add "Headers", Headers
Set Response = Client.GetJson(Url, Options)
End Sub
In the Immediate Window this prints:
ERROR - WebHelpers.ParseByFormat: 11000, An error occurred during parsing
10001: Error parsing JSON:
Please set
^
Expecting '{' or '['
ERROR - WebHelpers.ParseByFormat: 11000, An error occurred during parsing
10001: Error parsing JSON:
Please set
^
Expecting '{' or '['
ERROR - WebHelpers.ParseByFormat: 11000, An error occurred during parsing
10001: Error parsing JSON:
Por favor e
^
Expecting '{' or '['
ERROR - WebHelpers.ParseByFormat: 11000, An error occurred during parsing
10001: Error parsing JSON:
Por favor e
^
Expecting '{' or '['