var data = {
"file": "<InventoryFeed xmlns=\"http://walmart.com/\">\n <InventoryHeader>\n <version>1.4</version>\n </InventoryHeader>\n <inventory>\n <sku>JW00726</sku>\n <quantity>\n <unit>EACH</unit>\n <amount>25</amount>\n </quantity>\n </inventory>\n <inventory>\n <sku>JW00663</sku>\n <quantity>\n <unit>EACH</unit>\n <amount>20</amount>\n </quantity>\n </inventory>\n</InventoryFeed>\n"
};
var options = {
"method" : "POST",
"headers": {
"Authorization": "Basic "+Global_Auth,
"WM_QOS.CORRELATION_ID": Global_CORRELATION_ID,
"WM_SVC.NAME": Global_SVC_NAME,
"WM_SEC.ACCESS_TOKEN":GetAccessToken(),
"WM_CONSUMER.CHANNEL.TYPE": "#",
"Accept": "application/json",
"mimeType": "multipart/form-data",
"Content-Type": "application/x-www-form-urlencoded"
},
"payload" : data,
"muteHttpExceptions" : true
};
var url = "https://marketplace.walmartapis.com/v3/feeds?feedType=inventory";
var response = UrlFetchApp.fetch(url, options);
var res = JSON.parse(response.getContentText());
in API response getting 200 (ok) response but values are not updating into Walmart feed.
When I searched about the endpoint of
https://marketplace.walmartapis.com/v3/feeds?feedType=inventory
of Walmart API, I found 2 patterns.In this answer, I would like to propose an answer using above 2 documents.
Pattern 1:
In this pattern, the official document is used. In this case, the data is sent with
multipart/form-data
. When your script is modified, it becomes as follows. The data is used from your script.Modified script:
multipart/form-data
is requested with UrlFetchApp, it is not required to set the content type. It is automatically set with the boundary.data
is sent as form with the content type ofapplication/x-www-form-urlencoded
. I thought that this might be the reason of your issue.Pattern 2:
In this pattern, "Walmart Partner Apis Prod_Publish" at Postman is used. In this case, the data is sent with
application/json
. And the sample curl is as follows.This is converted to Google Apps Script.
Sample script:
Note:
"mimeType": "multipart/form-data"
is not used in the request header.data
and the values in the request header are correct values for using the API. Please be careful this.References: