我一直在尝试针对沙盒和生产使用Walmart Marketplace API进行身份验证,但到目前为止仍未成功。在所有情况下,当我对“令牌API”(https://sandbox.walmartapis.com/v3/token)进行请求ping时,我都会获得以下错误代码:“ SYSTEM_ERROR.GMP_GATEWAY_API”。我尝试使用JSON和XML进行身份验证,但是没有运气。
这是我的JSON请求:
{
url: 'https://sandbox.walmartapis.com/v3/token',
data: { grant_type: 'client_credentials' },
options: {
headers: {
Authorization: 'Basic <base64String>=',
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'WM_SVC.NAME': 'Walmart Marketplace',
'WM_QOS.CORRELATION_ID': '1bca34cd-478f-4022-8c13-9b88293f56b2',
'WM_SVC.VERSION': '1.0.0'
}
},
method: 'post'
}
这是我使用JSON遇到的错误:
error: [
{
code: 'SYSTEM_ERROR.GMP_GATEWAY_API',
description: 'Illegal character in query at index 172: http://partner-read-srvc-app.prod2.partnerreadservice1.catdev.prod.walmart.com/partner-read-srvc-app/services/org/client/search?_s=cross_ref_key==ClientId;cross_ref_value=="8cdc9a4f-3518-4941-9b62-5bc88bac5f3c;buId==0;martId==0',
info: 'System encountered some internal error.',
severity: 'ERROR',
category: 'DATA',
causes: [],
errorIdentifiers: {}
}
该错误提到了索引172,但我不确定它指的是什么。看完他们的文档here之后,我将按照信件的实现进行操作。
这是我对XML的要求
{
url: 'https://sandbox.walmartapis.com/v3/token',
data: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' +
'<grant_type>client_credentials</grant_type>',
options: {
headers: {
Authorization: 'Basic <base64String>=',
Accept: 'application/xml',
'Content-Type': 'application/xml',
'WM_SVC.NAME': 'Walmart Marketplace',
'WM_QOS.CORRELATION_ID': 'be1ff777-9c7b-4ca2-8b9c-ac31696dbf79',
}
},
method: 'post'
}
但这也失败了。
有人知道为什么这些请求可能会失败,并可能在JS中提供一个通过API进行身份验证的有效示例吗?
答案 0 :(得分:0)
bundler _1.9_ install
这对我有用。确保您具有正确的授权构建。格式为“ Basic Base64encode(cliendId:clientSecret)”
我认为您发送Grant_type属性的方式不正确。