1

I am trying to authenticate to walmart.com using Token-based authentication (New preferred method) on vba. You can read more here: https://developer.walmart.com/#/apicenter/marketPlace/latest#introduction

What can be the reason for the error message? How to fix this error? After all, Consumer id is not required in the code.

Base64EncodeString is my personal function. I checked how it works by comparing the result with web resources.

WalmartAPIUserKey - my ClientID

WalmartSecretKey - my ClientSecret

Dim xmlhttp As New MSXML2.XMLHTTP60    
Dim encodeData As String

encodeData = Base64EncodeString(WalmartAPIUserKey & ":" & WalmartSecretKey) 
xmlhttp.Open "POST", "https://marketplace.walmartapis.com/v3/token", False                       
xmlhttp.SetRequestHeader "WM_SVC.NAME", "Walmart marketplace"
xmlhttp.SetRequestHeader "WM_QOS.CORRELATION_ID", "123456abcdef"
xmlhttp.SetRequestHeader "Authorization", "Basic " & encodeData
xmlhttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.SetRequestHeader "Accept", "application/xml"
xmlhttp.send

MsgBox (xmlhttp.responseText)
Debug.Print (xmlhttp.responseText)

Set xmlhttp = Nothing

However, I get the following error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:errors xmlns:ns2="http://walmart.com/">
    <ns2:error>
        <ns2:code>SYSTEM_ERROR.GMP_GATEWAY_API</ns2:code>
        <ns2:description>consumer id not found in PRS</ns2:description>
        <ns2:info>System encountered some internal error.</ns2:info>
        <ns2:severity>ERROR</ns2:severity>
        <ns2:category>DATA</ns2:category>
        <ns2:causes/>
        <ns2:errorIdentifiers/>
    </ns2:error>
</ns2:errors>
pegasuspect
  • 991
  • 4
  • 15

2 Answers2

2

Maybe a side note but there should be a grant type sent by the looks of it i.e. body in send line should be

grant_type=client_credentials 

Info:

Request Parameters
Name        Description                             Required      Default        
grant_type  The type of access token to be issued   Yes     client_credentials        

** Note:The value of the grant_type should always be 'client_credentials' to get the correct access token **
QHarr
  • 83,427
  • 12
  • 54
  • 101
0

As per Walmart Token API You need to pass grant_type=client_credentials as request body to get an access_token for other API calls.

Gomzy
  • 431
  • 4
  • 14