Error updating item count on Amazon using API

I read a lot of Amazon API documentation and still have not understood what error I am getting, the documentation does not provide useful examples.

I use this to update my inventor:

I read various documents, each of which points to a new service URL, and I'm really confused about this.

config.ServiceURL = "https://mws.amazonservices.co.uk/FulfillmentInventory/2011-10-01"; config.ServiceURL = "https://secure.amazon.co.uk/exec/panama/seller-admin/catalog-upload/modify-only"; 

My code to start the process and send the request:

 String accessKeyId = "#"; String secretAccessKey = "#"; String merchantId = "#"; String marketplaceId = "#"; MemoryStream stream = new MemoryStream(); stream = GenerateInventoryDocument(txtxSku.Text, merchantId, txtQuantity.Text); const string applicationName = "C#"; const string applicationVersion = "4"; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, applicationName, applicationVersion, config); MarketplaceWebService.Model.SubmitFeedResponse response = new MarketplaceWebService.Model.SubmitFeedResponse(); MarketplaceWebService.Model.SubmitFeedRequest request = new MarketplaceWebService.Model.SubmitFeedRequest(); request.Merchant = merchantId; request.MarketplaceIdList = new MarketplaceWebService.Model.IdList(); request.MarketplaceIdList.Id = new List<string>(new string[] { marketplaceId }); request.FeedContent = stream; request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent); request.FeedContent.Position = 0; request.FeedType = "_POST_INVENTORY_AVAILABILITY_DATA_"; SubmitFeedSample.InvokeSubmitFeed(service, request); 

Function GenerateInventoryDocument() :

 MemoryStream myDocument = new MemoryStream(); string myString; //Add the document header. myString = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; this.AddStringToStream(ref myString, myDocument); myString = "<AmazonEnvelope xsi:noNamespaceSchemaLocation=\"amzn-envelope.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"; this.AddStringToStream(ref myString, myDocument); myString = "<Header>"; this.AddStringToStream(ref myString, myDocument); myString = "<DocumentVersion>1.01</DocumentVersion>"; this.AddStringToStream(ref myString, myDocument); myString = "<MerchantIdentifier>" + merchantID + "</MerchantIdentifier>"; this.AddStringToStream(ref myString, myDocument); myString = "</Header>"; this.AddStringToStream(ref myString, myDocument); myString = "<MessageType>Inventory</MessageType>"; this.AddStringToStream(ref myString, myDocument); myString = "<Message>"; this.AddStringToStream(ref myString, myDocument); myString = "<MessageID>1</MessageID>"; this.AddStringToStream(ref myString, myDocument); myString = "<OperationType>Update</OperationType>"; this.AddStringToStream(ref myString, myDocument); myString = "<Inventory>"; this.AddStringToStream(ref myString, myDocument); myString = "<SKU>" + sku + "</SKU>"; this.AddStringToStream(ref myString, myDocument); myString = "<FulfillmentLatency>1</FulfillmentLatency>"; this.AddStringToStream(ref myString, myDocument); myString = "<Quantity>" + quantity + "</Quantity>"; this.AddStringToStream(ref myString, myDocument); myString = "</Inventory>"; this.AddStringToStream(ref myString, myDocument); myString = "</Message>"; this.AddStringToStream(ref myString, myDocument); myString = "</AmazonEnvelope>"; this.AddStringToStream(ref myString, myDocument); return myDocument; 

When I use this url:

 config.ServiceURL = "https://mws.amazonservices.co.uk/FulfillmentInventory/2011-10-01"; 

I get the following error response:

 <ErrorResponse xmlns="http://mws.amazonaws.com/FulfillmentInventory/2011-10-01/"> <Error> <Type>Sender</Type> <Code>NoSuchVersion</Code> <Message>The requested version ( 2010-01-01 ) is not valid.</Message> <Detail/> </Error> <RequestID>f35d1eb0-b8e7-40c0-8394-027619fb0762</RequestID> </ErrorResponse> 

And when I use this service URL, which I read in another document:

 config.ServiceURL = "https://secure.amazon.co.uk/exec/panama/seller-admin/catalog-upload/modify-only"; 

I get the following error response:

 <BusinessLogicError>CUSTOMER_UNAUTHORIZED</BusinessLogicError> 

Please let me know if something is wrong in this code, as I follow the documents completely, and this was the third day I spent on it. Maybe I'm going crazy: D

These are small problems, and I cannot understand them.

+4
source share
1 answer

There are several errors in the code. I assume that you want to update the inventory that you do yourself (unlike the FBA ). I also assume that you are the Pro Merchant, which Amazon is required to use any MWS API.

The right serviceUrl for the UK is https://mws.amazonservices.co.uk . The correct feedType for updating / adding resources is _POST_FLAT_FILE_LISTINGS_DATA_ . There are other types of feed that you can use. See the section "Enumerating the feed type" in the Feed API Link . This type of feed is a tab delimited file, and you can find the template here. There is also an XML type, but you must have the correct account to use this feed submission type. These types of accounts are by invitation only.

Assuming you have downloaded the C # Feeds API , you should look at the MarketplaceWebServiceSamples.cs file, which is included in the MarketplaceWebService.Samples project inside the solution. This file has a bunch of sections that have been commented out. Find the one that deals with the Submit Feed action and use it to learn how to submit the feed.

You should spend some more time reading the feed API documentation , especially in the feed type enumeration section, since there are other types of feeds that you can use (tab only).

+4
source

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


All Articles