【发布时间】:2020-07-03 03:15:32
【问题描述】:
我正在使用 MS Access 中的 VBA 访问 API。
我的 HTTP 脚本运行良好,我可以发布和创建客户,但我的地址字段有问题。 这是因为它不仅仅是一个字段,还有我不知道其语法的子字段。
任何人都可以提供 VBA 中 -d cURL 语法子字段的语法吗?
reqBody = "description=" & desc & _
"&email=" & pEmail & _
"&name=" & pName & _
"&phone=" & pPhone
Set httpReq = CreateObject("MSXML2.ServerXMLHTTP")
httpReq.Open "POST", API_URL, False
httpReq.setRequestHeader "Authorization", "Bearer " & api_key
httpReq.send reqBody
strResponse = httpReq.responseText
来自 API 的文档:
> address optional dictionary The customer’s address.
>
> Address.line1 REQUIRED Address line 1 (e.g., street, PO Box, or
> company name).
>
> address.city optional City, district, suburb, town, or village.
>
> address.country optional Two-letter country code (ISO 3166-1 alpha-2).
>
> address.line2 optional Address line 2 (e.g., apartment, suite, unit,
> or building).
>
> address.postal_code optional ZIP or postal code.
>
> address.state optional State, county, province, or region.
【问题讨论】:
-
您尝试添加
"&address.city=" & yourCity等吗? stripe.com/docs/api ? -
或者您可能会发现使用github.com/VBA-tools/VBA-JSON 并发送 JSON 格式的请求更容易。
-
谢谢各位,我找到了一个非常随机的答案! @TimWilliams我不知道当文档没有提到 JSON 请求时我能做到这一点.. 我知道该怎么做:(
标签: vba ms-access curl xmlhttprequest