1

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?

thexyman
  • 591
  • 1
  • 5
  • 13
  • Is the '=' after the part of your JSON template, or an editing error? Use " for quotes, and maybe check a sample with a JSON validator. Other than that it looks ok at first glance. I've got code for getting a token, but not in JS. If that doesn't work, can you post your code? – toastifer May 12 '20 at 14:56

1 Answers1

1
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.

kushan85
  • 102
  • 1
  • 9
  • thanks for response @kushan85. So in the end, since this is a 3rd party development, the issue was with the API credentials not being correctly activated by client! – thexyman May 15 '20 at 14:32