c# – 使用API​​更新Amazon上的项目数量时出错

我已经阅读了很多关于Amazon API的文档,但我仍然不清楚我收到的错误,文档没有提供有用的示例.

我用它来更新我的发明:

我已经阅读了不同的文档,每个文档都说明了一个新的服务URL,我对此感到很困惑.

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";

我启动进程和发送请求的代码是:

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);

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;

当我使用此URL时:

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

我收到以下错误响应:

<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>

当我使用我在另一个doc上阅读的服务URL时:

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

我收到以下错误响应:

<BusinessLogicError>CUSTOMER_UNAUTHORIZED</BusinessLogicError>

如果这段代码有问题请告诉我,因为我完全关注这些文件,这也是我花在这上面的第3天.也许我正在失去理智:D

这些是小问题,我无法弄明白.

解决方法:

您的代码存在一些问题.我假设您要更新自己正在实现的库存(而不是FBA).我还假设您是亚马逊要求使用任何MWS API的专业商家.

英国的正确serviceUrl是https://mws.amazonservices.co.uk.用于更新/添加库存的正确feedType是_POST_FLAT_FILE_LISTINGS_DATA_.您可以使用其他Feed类型.请参阅Feeds API reference的Feed Type Enumeration部分.此类Feed是一个制表符分隔文件,您可以找到模板here.还有一种XML类型的Feed,但您必须拥有正确的帐户才能使用此类型的提交提交.这些类型的帐户仅限受邀者.

假设您已经下载了C# Feeds API,那么您应该查看解决方案内MarketplaceWebService.Samples项目中包含的MarketplaceWebServiceSamples.cs文件.这个文件有一堆已经注释掉的部分.找到处理提交Feed操作的操作,并使用它来了解如何提交Feed.

您应该花更多时间阅读Feeds API documentation,尤其是Feed Type Enumeration部分,因为您可以使用其他类型的Feed(仅限制表符分隔).

上一篇:【AWS征文】企业和个人用云服务,为什么要选择AWS?


下一篇:数据库