In this blog post, I will try to cover how to send item quantity data to Amazon and parse the results from Amazon using AWS. We used C# with Amazon SDK leveraging AWS.

Scenario:

We get the list of items that had change in available qty within the last hour. The data is parsed within C# application. You can do other data related operations such as whether the item is valid or if there was really a change in last available qty or not. I am not covering them here.

Next the main aspect this blog is to cover what we need to reference in C# standalone application. You can download Amazon SDK for C# and incorporate them in your project/solution file.

We also need below reference values which you can gather from Amazon Seller.

                       MerchantID

                       ServiceUrl

                       MarketPlaceId

                       AccessKeyID

                       SecretAccessKey

If this C# application is going to submit data to Amazon USA, then ServiceURL value is something like https://mws.amazonservices.com

Since we are going to update the Qty, we will be using in this example submit operation named “_POST_INVENTORY_AVAILABILITY_DATA_”

Once we have the above credentials and setup ready, next is build XML file that we need to submit. Build XML file in C# using file operations & string builder. Example of what XML should look like:

1.01 nnnnnnnnnn
Inventory 1 Update Item123 99 MFN

This XML file contains list of item(s) that need Qty update. The SwitchFulfillmentTo value is important.

Below is sample code. Note:

  1. Path is the XML file produced above.
  2. MD5Content is important and you can use what SDK offers.
  3. Reference/use MktWebClient and MktWebServiceConfig from SDK.
  4. CustomLog is function that shows output on screen and/or logs to file.
try { SubmitFeedRequest feedRequest = new SubmitFeedRequest(); feedRequest.Merchant = _merchantId; feedRequest.FeedContent = File.Open(Path, FileMode.Open, FileAccess.Read); feedRequest.ContentMD5 = CalculateContentMD5(feedRequest.FeedContent); MktWebServiceConfig config = new MktWebServiceConfig(); config.ServiceURL = _serviceUrl; config.SetUserAgentHeader(“POSTQTY”, “1.0”, “C Sharp”); feedRequest.FeedContent.Position = 0; feedRequest.FeedType = “_POST_INVENTORY_AVAILABILITY_DATA_”; MktWebClient client = new MktWebClient (_accessKeyId, _secretAccessKey, config); SubmitFeedResponse feedResponse = client.SubmitFeed(feedRequest); FeedSubmissionInfo feedInfo = feedResponse.SubmitFeedResult.FeedSubmissionInfo; feedId = feedInfo.FeedSubmissionId.ToString(); } catch (Exception ex) { customLog (ex.Message + “\n” + ex.Source + “\n” + ex.Data + “\n” + ex.StackTrace); } customLog (“XML file generated : ” + Path + “\nRequest submitted to AWS. Feed Submission ID : ” + feedId + “\n\n”);

Next step is to find if the feedID received from Amazon is success or errored out or had warnings. If not success, how to tweak them further. All these details will be covered in another blog.

Feel free to contact us for any questions.