您好我正在调用API并使用winhttp请求和GET方法。我在send方法中传递了json样式参数,但它无法被接受。我最终得到了错误消息:
{"代码":" INS03","说明":"需要事件ID"," requestId" :" _181603230829162847306080""数据":{}," validationErrors":空}
这看起来很奇怪,因为我确实传递了事件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
我的代码有问题吗?
提前谢谢你,
瓦迪姆
答案 0 :(得分:1)
对于GET
请求,应该组成查询字符串。
您的数据无法在Send
中传递,但在查询字符串中传递:
.Open "GET", inventory_URL & "?eventid=9445148", True
检查GET vs POST。