I'm trying to figure out how to send a successful request to Walmart's Update bulk inventory POST endpoint.
It's a little bit confusing since the content-type format is multipart/form-data which means that user needs to provide file. But for my use case that isn't possible since I only have a JS object to work with.
But looking at Walmart's documentation is shows an example request being sent as JSON so I've taken the below approach:
const jsonData = JSON.stringify({
InventoryHeader: {
version: '1.4',
},
Inventory: walmartData.inventory_items.reduce(
(acc, { sku, quantity }) => {
acc.push({
sku: encodeSku(sku),
quantity,
});
return acc;
},
[],
),
});
const data = new FormData();
data.append('json', jsonData);
const needleOpts = {
headers: {
...data.getHeaders(),
...buildHeaders(), // builds auth headers
},
};
const queryObject = {
feedType: 'inventory',
shipNode: 'xyz,
};
const query = queryString.stringify(queryObject, {
encode: false,
arrayFormat: 'bracket',
});
const url = `https://sandbox.walmartapis.com/v3/feeds?${query}`;
const result = await needle('post', url, data, needleOpts);
return result.body;
The thing is I get back an feedId which suggests that the response is successful but when I then try to fetch the feed I get back the following error:
{
"feedId": "3DD1DE30885E45BA8EB1CBFC94A41FEA@AQkBAQA",
"feedStatus": "ERROR",
"shipNode": null,
"submittedBy": null,
"ingestionErrors": {
"ingestionError": [
{
"type": "SYSTEM_ERROR",
"code": "PDR-0014",
"field": null,
"description": "INTERNAL SERVER ERROR"
}
]
},
"itemsReceived": 0,
"itemsSucceeded": 0,
"itemsFailed": 0,
"itemsProcessing": 0,
"offset": 0,
"limit": 50,
"itemDetails": {
"itemIngestionStatus": []
},
"additionalAttributes": null
}
In addition, when I try to fetch all inventory feeds I get back the following:
{
"totalResults": 0,
"offset": 0,
"limit": 50,
"results": {
"feed": null
}
}
This tells me that the inventory feed is not being created.
As far as I can tell the code I have looks okay but I can't understand why the feed isn't being created, also to note, the fact that the API is sandbox shouldn't make a difference.
Does anyone have any experience with this API and in particular sending request with JSON? Should the JSON object be in a file format?
Any ideas would be appreciated.