1

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

{"code":"INS03","description":"需要事件 ID","re​​questId":"_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

我的代码有问题吗?

先感谢您,

瓦迪姆

4

1 回答 1

1

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

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

检查GET 与 POST

于 2016-08-23T19:57:46.437 回答