我正在尝试通过 api 在 excel 中创建与 mollie 的付费链接
当我只使用 curl 时,下面的工作:
curl -X POST https://api.mollie.com/v2/payments \
-H "Authorization: Bearer test_XXXXXXXXXXXXXX" \
-d "amount[currency]=EUR" \
-d "amount[value]=10.00" \
-d "description=Order #12345" \
-d "redirectUrl=https://webshop.example.org/order/12345/" \
在VBA中我写了
Sub paylink()
Dim Payload As String
Payload = "amount[currency]='EUR'&amount[value]=10.00&description=Order12345&redirectUrl=https://webshop.example.org/order/12345/"
TargetURL = "https://api.mollie.com/v2/"
Set httpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
httpReq.Open "post", TargetURL, False
httpReq.SetRequestHeader "Authorization", "Bearer test_XXXXXXXXXX"
httpReq.PostText Payload
httpReg.Send
httpReq.WaitForResponse
Debug.Print (httpReq.ResponseText)
End Sub
这个结果是
{"status":404,"title":"Not Found","detail":"Invalid resource endpoint","_links":{"documentation":{"href":"https://docs.mollie.com/guides/handling-errors","type":"text/html"}}}
我做错了什么?谢谢 JMP URL 确实是错误的/我对代码进行了更多编辑以使其正常工作
Sub paylink()
Dim Payload As String
Payload = "amount[currency]=EUR&amount[value]=10.00&description=Order12345&redirectUrl=https://webshop.example.org/order/12345/"
TargetURL = "https://api.mollie.com/v2/payments"
Set httpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
httpReq.Open "post", TargetURL, False
httpReq.SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
httpReq.SetRequestHeader "Authorization", "Bearer test_XXXXXXXXXXXXXX"
httpReq.Send Payload
httpReq.WaitForResponse
Debug.Print (httpReq.ResponseText)
End Sub