Walmart API - problem with the type of MIME download - mass creation / updating of elements that do not work

I can successfully make API calls for other Walmart API endpoints (in particular, endpoints of a GET request), but the mass element endpoint (POST request) leads to errors, although I seem to be all right.

Here is a link to this endpoint https://developer.walmartapis.com/#bulk-createupdate-items


HTTP RESPONSE INFORMATION

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

post method

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 (text only, no key for 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's "Advanced REST Client Application" as well as POSTMAN when making HTTP requests to eliminate issues related to my code.

I tried to tweak everything that came to mind.

I have other endpoints with GET requests, so I know this is not a problem with authentication, IP, firewall, or something like that.

I know the credentials created by the jar file provided by walmart (see the authentication section of the document https://developer.walmartapis.com/#jar-executable-recommended ) the URL you submit should be sent. Therefore, I know that this is not a problem generating the wrong key with the jar file.


Hypotheses:

  • Based on the answer, something should be wrong with the data or headers that I am sending.

Could not determine border from message!

sounds like xml doesn't have symmetric tags, but I checked this xml

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

But using this header does not 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 answer above (500, SYSTEM_ERROR.GMP_GATEWAY_API, Failed to determine the border from the message!)

Thus, it seems that Content-Type: application/xml can be excluded.

  • The walmart api documentation only gives an example of how to change the product or sku identifier, but not to create. I assume that I just omit the xml tags specific to updating the product id or sku, but this xml payload also leads to a 500 response.

I have no ideas, has anyone else got the opportunity to create / update elements for work? Does anyone have some sample code that really works?

+5
source share
4 answers

In case someone encounters this using PHP and is still experiencing problems even after trying to solve the OP (for example, a 500 response with the message “Could not determine the border from the message!” Or “Meeting the system with some internal error”, you can use cURL to automatically process the border for you by passing CURLOPT_POSTFIELDS as an array, for example:

 curl_setopt($c, CURLOPT_POSTFIELDS, ['file' => $xml]); 
+2
source

The problem was that he needed an HTTP request border.

since the mime type is multipart / form-data, it needs a few things:

  • The title bar should be Content-Type: multipart/form-data; boundary=qwerty Content-Type: multipart/form-data; boundary=qwerty , where qwerty is any arbitrary string that you select.
  • The payload body must begin with --qwerty and end with --qwerty--
+3
source

Here is an example of a work request:

 POST /v2/feeds?feedType=inventory Content-Length: 750 Content-Type: multipart/form-data; boundary=72c4c966adda8bba2e0b3ebc3176cc0c395dd8c8 Host: marketplace.walmartapis.com Accept: application/xml Accept-Encoding: gzip, deflate, br User-Agent: <...> Accept-Language: en-US WM_CONSUMER.CHANNEL.TYPE: <...> WM_CONSUMER.ID: <...> WM_SEC.TIMESTAMP: <...> WM_SEC.AUTH_SIGNATURE: <...> WM_SVC.NAME: Walmart Marketplace WM_QOS.CORRELATION_ID: <...> --72c4c966adda8bba2e0b3ebc3176cc0c395dd8c8 Content-Disposition: form-data; name="xml" Content-Length: 591 <?xml version="1.0" encoding="UTF-8"?> <InventoryFeed xmlns="http://walmart.com/"> <InventoryHeader> <version>1.4</version> </InventoryHeader> <inventory> <sku>sku</sku> <quantity> <unit>EACH</unit> <amount>1</amount> </quantity> <fulfillmentLagTime>5</fulfillmentLagTime> </inventory> </InventoryFeed> --72c4c966adda8bba2e0b3ebc3176cc0c395dd8c8-- 
0
source

Select your custom string, say arbString, for example. abcdefghijklmnop (any string that should not be repeated in your XML test)

Build your XML payload (file input stream) for bulk price / stock. Convert your payload to string using FileString = Ioutils.toString ("FIS", standardCharacterset.UTF_8).

Now add "- arbString / n / n" + FileString + "/ n - arbString -"

0
source

Source: https://habr.com/ru/post/1262675/


All Articles