VBA RESTful API GET方法问题

VBA RESTful API GET Method issue

您好,我正在调用 API 并使用 winhttp 请求和 GET 方法。我在发送方法中传递了一个 json 样式参数,但它无法被接受。我最终收到错误消息:

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

这看起来很奇怪,因为我确实传递了事件id参数,如下:

    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

我的代码有问题吗?

提前致谢,

瓦迪姆

对于GET请求查询字符串应该组成。 您的数据无法在 Send 中传递,但在查询字符串中传递:

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

检查GET vs POST