Reputation: 591
I’ve been trying to authenticate with the Walmart Marketplace API for both sandbox and production but have so far been unsuccessful. In all cases when I ping a request to the “Token API” (https://sandbox.walmartapis.com/v3/token) I get back the the following error code: “SYSTEM_ERROR.GMP_GATEWAY_API”. I’ve tried to authenticate with both JSON and XML but no luck.
Here is my request with 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'
}
Here is the error I'm getting with 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: {}
}
The error mentions index 172 but I'm not exactly sure what it's referring to. Having looked at their docs here I'm following the implementation to the letter.
Here is my request for 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'
}
But this is also fails.
Does anyone know why these requests may be failing and perhaps provide a working example in JS of a request to authenticate with the API?
Upvotes: 1
Views: 3347
Reputation: 102
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://sandbox.walmartapis.com/v3/token',
'headers': {
'WM_SVC.NAME': 'Walmart Marketplace',
'WM_QOS.CORRELATION_ID': 'test',
'Accept': 'application/json',
'Authorization': 'Basic afafaf...',
'WM_SVC.VERSION': ' 1.0.0',
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'grant_type': 'client_credentials'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
This works for me. Make sure you have the Authorization build correctly. it is in the format "Basic Base64encode(cliendId:clientSecret)"
I think the they way you are sending the grant_type attribute is incorrect.
Upvotes: 1