我有以下REST API文档,我试图看看是否可以在Classic ASP中完成。
目标网址为:
https://sandbox.cal-online.co.il/api/PayCalSDK/VerifyAndActivateForPaymentPage
{
TotalAmount: 1,
CurrencyCode: 1,
TransactionId: GUID,
Business: {
ApiKey: 'C89371AE-698F-4A15-BD35-2F58377A14F9', // test key
Description: ''
},
CreditTypes: [
{CreditTypeCode: 1, MaxNumberOfPayments: 1}
]
}
我拥有的是:
Set HTTP = CreateObject("MSXML2.serverXMLHTTP")
HTTP.setOption 2, 13056
HTTP.Open "GET", (url), false
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HTTP.setRequestHeader "Business.ApiKey", "C89371AE-698F-4A15-BD35-2F58377A14F9"
HTTP.setRequestHeader "transactionId", "397653"
HTTP.setRequestHeader "PayCalSDK.CreditType", "1"
HTTP.setRequestHeader "TotalAmount", "20.20"
HTTP.setRequestHeader "CurrencyCode", "1"
HTTP.setRequestHeader "payCalSdkCharge.ApiUrlPath", "http://www.domain.com"
HTTP.send("")
Response.write HTTP.responseText
Set HTTP = nothing
但是对于字段的格式有些不对,因为我收到了来自它们的错误响应:
回应是:
{"message":"An error has occurred."}
这个的正确语法是什么?
更新:
我也试过这段代码:
key = "C89371AE-698F-4A15-BD35-2F58377A14F9"
url = "https://m.cal-online.co.il/api/PayCalSDK/VerifyAndActivateForPaymentPage?"
str = "{ TotalAmount: 1, CurrencyCode: 1, TransactionId: 36985223, Business: { ApiKey: '" & key & "',Description: '' }, CreditTypes: [ {CreditTypeCode: 1, MaxNumberOfPayments: 1}] }"
Dim oXMLHttp
Set oXMLHttp=Server.Createobject("Msxml2.ServerXMLHTTP.6.0")
oXMLHttp.open "post", url & str,false
oXMLHttp.send
response.write oXMLHttp.responseText
Set oXMLHttp = Nothing
我得到同样的答复:
{"message":"An error has occurred."}
答案 0 :(得分:2)
C / O Lankymart通过评论提供帮助,试试这个
key = "C89371AE-698F-4A15-BD35-2F58377A14F9"
url = "https://m.cal-online.co.il/api/PayCalSDK/VerifyAndActivateForPaymentPage?"
str = "{ TotalAmount: 1, CurrencyCode: 1, TransactionId: 36985223, Business: { ApiKey: '" & key & "',Description: '' }, CreditTypes: [ {CreditTypeCode: 1, MaxNumberOfPayments: 1}] }"
Dim oXMLHttp
Set oXMLHttp=Server.Createobject("MSXML2.ServerXMLHTTP.6.0")
oXMLHttp.open "POST", url,false
oXMLHttp.setRequestHeader "Content-Type", "application/json"
oXMLHttp.send str
response.write oXMLHttp.responseText
Set oXMLHttp = Nothing