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

5
  • 1
    you should still include your best code effort so long as it fits the stackoverflow.com/help/mcve Commented Mar 1, 2018 at 20:52
  • 1
    @QHarr, Per your suggestion, my best code effort is now included :( Commented Mar 1, 2018 at 21:33
  • What references do you have added ? E.g. for WebClient Commented Mar 2, 2018 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. Commented Mar 2, 2018 at 16:39
  • I keep trying things, and still not successful, if anyone has an idea to help I thank you in advance!! :) Commented Mar 2, 2018 at 18:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.