0

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 '['

CTrim
  • 23
  • 1
  • 1
  • 6
  • 1
    you should still include your best code effort so long as it fits the https://stackoverflow.com/help/mcve – QHarr Mar 01 '18 at 20:52
  • 1
    @QHarr, Per your suggestion, my best code effort is now included :( – CTrim Mar 01 '18 at 21:33
  • What references do you have added ? E.g. for WebClient – QHarr Mar 02 '18 at 16:30
  • I imported the VBA-WEB tool by Tim Hall. I think it's for excel though, and I am using it in Access, hope it still works. Currently I have these references set- Visual Basic for Applications, Microsoft Access 14.0 Object Library, OLE Automation, Microsoft Office 14.0 Access database engine object, Microsoft Scripting Runtime, Microsoft WinHTTP Services, version 5.1, Microsoft Office 14.0 Object Library. – CTrim Mar 02 '18 at 16:39
  • I keep trying things, and still not successful, if anyone has an idea to help I thank you in advance!! :) – CTrim Mar 02 '18 at 18:06

0 Answers0