GoCardless API 使用 Classic ASP
GoCardless API using Classic ASP
我正在 vbscript 中创建以下请求并发送到 gocardless 沙箱:
url="https://api-sandbox.gocardless.com/"
typ="GET"
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open typ, url, False
xml.setRequestHeader "Authorization", "Bearer " & GCAccessToken
xml.SetRequestHeader "GoCardless-Version", "2015-07-06"
xml.SetRequestHeader "Accept","application/json"
xml.SetRequestHeader "Content-Type", "application/json"
xml.Send
GetGC = xml.responseText
Set xml = Nothing
尽管我做了任何调整,但我总是得到的回应是:
{"error":{"message":"not found","errors":[{"reason":"not_found","message":"not found"}],"documentation_url":"https://developer.gocardless.com/api-reference#not_found","type":"invalid_api_usage","request_id":"0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009","code":404}}
如有任何帮助,我们将不胜感激。已为 Stripe 成功完成类似操作,但现在需要使用 GC。
如果您阅读了 API
的回复
{
"error": {
"message": "not found",
"errors": [{
"reason": "not_found",
"message": "not found"
}
],
"documentation_url": "https://developer.gocardless.com/api-reference#not_found",
"type": "invalid_api_usage",
"request_id": "0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009",
"code": 404
}
}
错误似乎是 HTTP 状态代码 (与 RESTful APIs 一样) - 404 Not Found
查看响应中提供的文档 link;
404
Not Found. The requested resource was not found or the authenticated user cannot access the resource. The response body will explain which resource was not found.
所以问题可能是;
- 您使用提供的代码中的令牌进行身份验证失败。
- 您已通过身份验证但无权访问该资源。
- 您要查找的资源不存在。
在这个特定的例子中,我认为这是因为资源不存在,因为代码没有指定资源,只有 API 的基础 URL 不会'不构成您可以与之交互的 API 端点。
查看 the documentation 很明显,您需要在 URL 中提供一个有效端点,在撰写本文时,有 15 个核心端点和 2 个辅助端点可以交互。
例如,create payment request/response 看起来像;
POST https://api.gocardless.com/payments HTTP/1.1
{
"payments": {
"amount": 100,
"currency": "GBP",
"charge_date": "2014-05-19",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"links": {
"mandate": "MD123"
}
}
}
HTTP/1.1 201 (Created)
Location: /payments/PM123
{
"payments": {
"id": "PM123",
"created_at": "2014-05-08T17:01:06.000Z",
"charge_date": "2014-05-21",
"amount": 100,
"description": null,
"currency": "GBP",
"status": "pending_submission",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"amount_refunded": 0,
"links": {
"mandate": "MD123",
"creditor": "CR123"
}
}
}
不幸的是,问题中提供的代码示例并没有真正做任何事情,因此很难建议您正在尝试做什么。总之,我建议重新访问 the documentation for the API 并查看提供的示例。
我正在 vbscript 中创建以下请求并发送到 gocardless 沙箱:
url="https://api-sandbox.gocardless.com/"
typ="GET"
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open typ, url, False
xml.setRequestHeader "Authorization", "Bearer " & GCAccessToken
xml.SetRequestHeader "GoCardless-Version", "2015-07-06"
xml.SetRequestHeader "Accept","application/json"
xml.SetRequestHeader "Content-Type", "application/json"
xml.Send
GetGC = xml.responseText
Set xml = Nothing
尽管我做了任何调整,但我总是得到的回应是:
{"error":{"message":"not found","errors":[{"reason":"not_found","message":"not found"}],"documentation_url":"https://developer.gocardless.com/api-reference#not_found","type":"invalid_api_usage","request_id":"0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009","code":404}}
如有任何帮助,我们将不胜感激。已为 Stripe 成功完成类似操作,但现在需要使用 GC。
如果您阅读了 API
的回复{
"error": {
"message": "not found",
"errors": [{
"reason": "not_found",
"message": "not found"
}
],
"documentation_url": "https://developer.gocardless.com/api-reference#not_found",
"type": "invalid_api_usage",
"request_id": "0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009",
"code": 404
}
}
错误似乎是 HTTP 状态代码 (与 RESTful APIs 一样) - 404 Not Found
查看响应中提供的文档 link;
404
Not Found. The requested resource was not found or the authenticated user cannot access the resource. The response body will explain which resource was not found.
所以问题可能是;
- 您使用提供的代码中的令牌进行身份验证失败。
- 您已通过身份验证但无权访问该资源。
- 您要查找的资源不存在。
在这个特定的例子中,我认为这是因为资源不存在,因为代码没有指定资源,只有 API 的基础 URL 不会'不构成您可以与之交互的 API 端点。
查看 the documentation 很明显,您需要在 URL 中提供一个有效端点,在撰写本文时,有 15 个核心端点和 2 个辅助端点可以交互。
例如,create payment request/response 看起来像;
POST https://api.gocardless.com/payments HTTP/1.1
{
"payments": {
"amount": 100,
"currency": "GBP",
"charge_date": "2014-05-19",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"links": {
"mandate": "MD123"
}
}
}
HTTP/1.1 201 (Created)
Location: /payments/PM123
{
"payments": {
"id": "PM123",
"created_at": "2014-05-08T17:01:06.000Z",
"charge_date": "2014-05-21",
"amount": 100,
"description": null,
"currency": "GBP",
"status": "pending_submission",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"amount_refunded": 0,
"links": {
"mandate": "MD123",
"creditor": "CR123"
}
}
}
不幸的是,问题中提供的代码示例并没有真正做任何事情,因此很难建议您正在尝试做什么。总之,我建议重新访问 the documentation for the API 并查看提供的示例。