翻译“ -d”在执行HTTP请求时在VBA中
我尝试通过发送带有VBA的HTTP请求来获取由“ Template_ID”过滤的IAUDITOR的列表。目前,我有此代码返回所有操作的列表:
Sub Get_Data()
Dim hReq As Object
Dim sht As Worksheet
Dim authKey As String
Dim response As String
authKey = "d8a0df7d7e1XXXXXXXXXXXXXXXXXXXXXXXXff3c765cf2fcf"
Set sht = Sheets(1)
Dim strUrl As String
strUrl = "https://api.safetyculture.io/tasks/v1/actions/list"
Set hReq = CreateObject("MSXML2.XMLHTTP")
With hReq
.Open "POST", strUrl, False
.SetRequestHeader "Authorization", "Bearer " & authKey
.SetRequestHeader "Content-Type", "application/json"
.Send
End With
response = hReq.ResponseText
'MsgBox Len(response)
sht.Range("A1") = response
End Sub
现在我想将过滤器“翻译”到VBA,但我不知道该怎么做。
这是我有关网站的API文档: https://developer.safether.safetyculture.io/#actions
因此,我想在VBA中翻译的内容在HTTP代码中看起来像这样:
curl -X POST "https://api.safetyculture.io/tasks/v1/actions/list" \
-H "Authorization: Bearer {api_token}" \
-d {
"template_id": {
"operator": 7,
"value": ["fc2e53f6-4712-4ca5-b681-aba3ac954217"]
}
}
我非常感谢您提供的任何帮助。
问候, 加宾
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据此线程:
您可以通过将其作为发送函数中的值传递给帖子请求,将数据添加到帖子请求中:
值由A&字符串中的符号。
According to this thread:
https://www.vbforums.com/showthread.php?592624-Posting-data-using-XMLHttpRequest
you can add Data to a POST Request by passing it as a value in the send function:
Values are differentiated by a & Symbol inside the string.
我做到了!!! :d
这是我的最终代码:
非常感谢@codingwolf,他把我朝着正确的方向。
祝您有美好的互联网。
加宾,
I've did it !!! :D
Here is my final code:
Huge thanks to @CodingWolf , he put me on the right direction.
Have a nice day internet.
Gabin,