我使用Request.ServerVariables在经典的asp中从GoCardless获取Webhook响应,该asp调用了我服务器上的页面http:/www.example.com/webhook.asp
我在webhook.asp中的代码:
For Each var in Request.ServerVariables
WriteLog var & " = " & Request.ServerVariables(var) , "gocardless"
Next
输出正常,我可以阅读
Content-Length: 353
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Host: admin.controle-reglementaire.fr
User-Agent: gocardless-webhook-service/1.1
Origin: https://api.gocardless.com
Webhook-Signature: 71ef0f915569e082f090f5150fdf4144be4fed242b1253ad620544c4dd8d615a
我的代码工作正常,但无法检索
附带的json我必须获得完整的响应信息,如Gocardless Guide
所示。Originhttps://api.gocardless.com
User-Agentgocardless-webhook-service/1.1
Content-Typeapplication/json
Webhook-Signature71ef0f915569e082f090f5150fdf4144be4fed242b1253ad620544c4dd8d615a
Corps
{
"events": [
{
"id": "EVTESTC4TEBZP2",
"created_at": "2019-12-21T10:18:30.168Z",
"resource_type": "payments",
"action": "failed",
"links": {
"payment": "index_ID_123"
},
"details": {
"origin": "bank",
"cause": "insufficient_funds",
"scheme": "sepa_core",
"reason_code": "AM04",
"description": "The customer's account had insufficient funds to make this payment."
},
"metadata": {}
}
]
}
我应该添加什么代码以获取位于标头中的json响应
thx
答案 0 :(得分:0)
在Google搜索超过48小时后,这解决了我的问题
Dim lngBytesCount, bstring
If Request.TotalBytes > 0 Then
lngBytesCount = Request.TotalBytes
bstring= BytesToStr(Request.BinaryRead(lngBytesCount))
response.Clear
WriteLog bstring , "gocardless"
end if
Function BytesToStr(bytes)
Dim Stream
Set Stream = Server.CreateObject("Adodb.Stream")
Stream.Type = 1 'adTypeBinary
Stream.Open
Stream.Write bytes
Stream.Position = 0
Stream.Type = 2 'adTypeText
Stream.Charset = "UTF-8"
BytesToStr = Stream.ReadText
try = BytesToStr
Stream.Close
Set Stream = Nothing
End Function
答案 1 :(得分:0)
好的,谢谢大家的帮助,但这是帮助解决我的问题的完整解决方案,而且效果很好
open