如何将cURL请求重写为VBA WinHttp.WinHttpRequest.5.1



我有一个cURL请求,我可以通过Windows PowerShell运行:

curl -k -X GET "https://api.xxx.com/open/api/exchange-rates/v1/exchange-rates?validityDateTime=2023-03-30T06%3A00%3A00.000Z" -H  "accept: */*" -H  "x-correlation-id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -H  "x-api-key: Bearer aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaaa"

(URL和API密钥替换为"x"或"a"

我如何通过MS Access VBA请求这个,与WinHttp.WinHttpRequest.5.1

?

figure out:

Dim HTTPReq As Object
Dim URL As String
Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "https://api.xxx.com/open/api/exchange-rates/v1/exchange-rates/USD?validityDateTime=2019-03-27T06%3A00%3A00.000Z"
HTTPReq.Open "GET", URL, False
HTTPReq.setRequestHeader "Accept", "*/*"
HTTPReq.setRequestHeader "x-correlation-id", "xxxxxxxxxxxxx-xxxxxx-xxxxxxxxx"
HTTPReq.setRequestHeader "x-api-key", "Bearer aaaaaaa-aaaaaaaaa-aaaaaaaaa"
HTTPReq.send
Debug.Print HTTPReq.responseText
Set HTTPReq = Nothing

如果有人觉得有帮助的话:)

相关内容

  • 没有找到相关文章

最新更新