Vadim Serebrinskiy
Vadim Serebrinskiy

Reputation: 13

VBA RESTful API GET Method issue

Hi I'm calling an API and using the winhttp request and the GET method. I'm passing a json style parameter in the send method but it just can't get accepted. I end up with the error message:

{"code":"INS03","description":"Event ID required","requestId":"_181603230829162847306080","data":{},"validationErrors":null}

Which seems weird because I am indeed passing the event id parameter, as follows:

    inventory_URL = "https://api.stubhub.com/search/inventory/v1"

    Dim oRequest As WinHttp.WinHttpRequest
    Dim sResult As String

    Set oRequest = New WinHttp.WinHttpRequest
    With oRequest
        .Open "GET", inventory_URL, True
        .setRequestHeader "Authorization", "Bearer " & access_token
        .setRequestHeader "Accept", "application/json"
        .setRequestHeader "Accept-Encoding", "application/json"
        .send ("{""eventid"":""9445148""}")
        .waitForResponse
        sResult = .responseText
        Debug.Print sResult
        sResult = oRequest.Status
        Debug.Print sResult
   End With

Is there any issue with my code?

Thank you in advance,

Vadim

Upvotes: 1

Views: 1539

Answers (1)

gembird
gembird

Reputation: 14053

For GET request query string should be composed. Your data can't be passed in Send but in query string:

.Open "GET", inventory_URL & "?eventid=9445148", True

Check GET vs POST.

Upvotes: 1

Related Questions