我的工作环境是Visual Studio 2008 C#
我正在使用Amazon WebService,我想使用SOAP从Amazon获取数据,但是当我尝试传递IDType = UPC时,它给出了以下错误消息,那么我该怎么做呢?
错误:
036725229884 is not a valid value for ItemId. Please change this value and retry your request
mycode的:
ItemLookupRequest request1 = new ItemLookupRequest();
request1.IdType = ItemLookupRequestIdType.UPC;
request1.IdTypeSpecified = true;
request1.ItemId = new string[] { ProductID };
request1.ResponseGroup = new string[] { "Request", "Large", "OfferFull", "BrowseNodes" };
request1.MerchantId = "All";
request1.Condition = Condition.All;
request1.SearchIndex = "Books";
注意:
如何添加多个SearchIndex(“书籍”,“照片”,“视频”)?
我使用了以下WebService:
http://webservices.amazon.com/AWSECommerceService/2009-11-01/US/AWSECommerceService.wsdl
解决方法:
也厌倦了UPC和EAN之间的区别.
UPC = 12 digits,
EAN = 13 digits
如果您只是将UPC 738678251584(12位数)或EAN 3253581057803(13位数)打入Amazon.com,它将在说明中显示为UPC,但使用API时,您必须在搜索时指定EAN.
我们有两种产品,您需要相应地指定搜索类型,否则将无法找到.
编辑:或者您可以将0添加到任何12位数字,并始终搜索EAN.这可能是最好的解决方案.根据定义“0” + UPC = EAN
这个请求对我有用(searchType是UPC或EAN):
ItemLookup itemLookup = new ItemLookup()
{
AssociateTag = "XXXXX-20",
};
itemLookup.AWSAccessKeyId = ACCESS_ID;
ItemLookupRequest itemLookupRequest = new ItemLookupRequest();
itemLookupRequest.IdTypeSpecified = true;
itemLookupRequest.IdType = searchType;
itemLookupRequest.SearchIndex = "All";
itemLookupRequest.ItemId = upcEanList;
itemLookupRequest.ResponseGroup = new[] { "OfferSummary", "ItemAttributes" };
itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest };