Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Walmart API - payload mime type issue - bulk create/update items not working

I am able to make API calls to other Walmart API endpoints successfully (specifically the GET request endpoints), but the bulk items endpoint (a POST request) results in an errors, even though I seem to have everything correct.

Here is the reference to that endpoint https://developer.walmartapis.com/#bulk-createupdate-items


HTTP RESPONSE META INFO

500 Internal Server Error

xml

HTTP RESPONSE

<?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>Couldn't determine the boundary from the message!</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>

HTTP REQUEST:

url https://marketplace.walmartapis.com/v2/feeds?feedType=item

method POST

request headers

WM_SVC.NAME: Walmart Marketplace
WM_CONSUMER.ID: {my consumer id key}
WM_QOS.CORRELATION_ID: {my arbitrary text key}
Content-Type: multipart/form-data
Accept: application/xml
WM_SEC.AUTH_SIGNATURE:{my jar-file-generated key}
WM_SEC.TIMESTAMP:{my jar-file-generated timestamp}

POST payload (just text, no key for the parameter)

<?xml version="1.0" encoding="UTF-8"?>
<MPItemFeed xmlns="http://walmart.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://walmart.com/ MPItem.xsd ">
  <MPItemFeedHeader>
    <version>2.1</version>
    <requestId>qqq</requestId>
    <requestBatchId>qqq1</requestBatchId>
  </MPItemFeedHeader>
  <MPItem>
    <sku>qqq</sku>
    <Product>
      <productName>QQQ 1-Foot S-Video Male to 2 S-Video Female Y Cable (CSV2F)</productName>
      <longDescription><![CDATA[<div class="productDescriptionWrapper"> QVS Premium S-Video Mini4 Male to Two Female Splitter Cable CSV2F A/V Device Cables <div class="emptyClear">
      </div>
      </div>]]></longDescription>
      <shelfDescription><![CDATA[QVS 1-Foot S-Video Male to 2 S-Video Female Y Cable (CSV2F)]]></shelfDescription>
      <shortDescription>QQQ 1-Foot S-Video Male to 2 S-Video Female Y Cable (CSV2F)</shortDescription>
      <mainImage>
        <mainImageUrl>http://images.antonline.com/img-main/500/037229400328.jpg</mainImageUrl>
      </mainImage>
      <productIdentifiers>
        <productIdentifier>
          <productIdType>Item ID</productIdType>
          <productId>46817049</productId>
        </productIdentifier>
      </productIdentifiers>
      <productTaxCode>2038710</productTaxCode>
      <Electronics>
        <brand>QQQ</brand>
        <ElectronicsCables>
        </ElectronicsCables>
      </Electronics>
    </Product>
    <price>
      <currency>USD</currency>
      <amount>12.34</amount>
    </price>
    <shippingWeight>
      <value>1.234</value>
      <unit>LB</unit>
    </shippingWeight>
  </MPItem>
</MPItemFeed>

NOTES:

I tried using Google' Advanced REST Client Application as well as POSTMAN when making http requests, in order to rule out issues stemming from my code.

I've tried tweaking everything that came to mind.

I got other endpoints having GET requests to work, so I know it's not an issue with authentication, IP, firewall, or anything like that.

I know the credentials generated by the jar file provided by walmart (see the authentication section of the documention https://developer.walmartapis.com/#jar-executable-recommended ) has to be fed the url you're sending to. So I know it's not an issue of generating the wrong key with the jar file.


HYPOTHESES:

  • Based on the response, something must be wrong with the data or headers I'm sending.

Couldn't determine the boundary from the message!

sounds like the xml is doesn't have balanced tags, but I've validated this xml

  • The walmart api documentation for this endpoint says to use the header Content-Type: multipart/form-data;. So I did, results in the failure response.

But using this header doesn't seem to make sense to me, since the payload body is an xml string. Shouldn't it be Content-Type: application/xml? I tried this too, but it failed with the failed response above (500, SYSTEM_ERROR.GMP_GATEWAY_API, Couldn't determine the boundary from the message!)

So it seems Content-Type: application/xml can be ruled out.

  • The walmart api documentation gives example of only how to change product id or sku, but not for creating. I assume I just omit the xml tags specific to updating product id or sku, but that xml payload also results in the 500 response.

I'm out of ideas, has anyone else gotten bulk create/update items to work? Anyone have example code that actually works?

like image 932
ahnbizcad Avatar asked Jan 12 '17 03:01

ahnbizcad


1 Answers

In case anyone is stumbling across this using PHP and still having trouble even after trying OP's solution (e.g. 500 response with message "Couldn't determine the boundary from the message!" or "System encountered some internal error", you can use cURL to automatically handle the boundary for you by passing CURLOPT_POSTFIELDS as an array, like so:

curl_setopt($c, CURLOPT_POSTFIELDS, ['file' => $xml]);
like image 180
ShaneOH Avatar answered Sep 23 '22 15:09

ShaneOH