亚马逊MWS Boto get_matching_product_for_id

时间:2015-07-08 10:41:22

标签: python amazon-web-services boto amazon-mws

我是Python和Boto的新手。我已成功连接并使用boto for

检索结果
mws = MWSConnection(accessKeyId,secretKey,Merchant=merchantId)
response = mws.list_matching_products(MarketplaceId=marketplaceId,Query="Shopkins")

我正在尝试通过UPC查找项目,这是我的代码:

mws = MWSConnection(accessKeyId,secretKey,Merchant=merchantId)
response = mws.get_matching_product_for_id(MarketplaceId=marketplaceId,IdType="UPC",IdList="013138304582")

我已经在亚马逊MWS暂存器中测试了UPC,以验证它确实产生了结果。但当我用boto运行时,我得到:

InvalidParameterValue
line 53, in <module>
response = mws.get_matching_product_for_id(MarketplaceId=marketplaceId,IdType="UPC",IdList="013138304582")
File "D:\Python\lib\site-packages\boto\mws\connection.py", line 158, in requires
return func(*args, **kw)
File "D:\Python\lib\site-packages\boto\mws\connection.py", line 81, in wrapper
return func(self, *args, **kw)
File "D:\Python\lib\site-packages\boto\mws\connection.py", line 252, in wrapper
return func(self, request, response, *args, **kw)
File "D:\Python\lib\site-packages\boto\mws\connection.py", line 798, in get_matching_product_for_id
return self._post_request(request, kw, response)
File "D:\Python\lib\site-packages\boto\mws\connection.py", line 323, in _post_request
response.reason, body)
boto.mws.exception.InvalidParameterValue: InvalidParameterValue: Bad Request 
One or more parameter values in the request is invalid.
Found duplicate value for IdList: 1

以下是他们网站上有关该功能的boto文档:

MWSConnection.get_matching_product_for_id(*args, **kw)
MWS GetMatchingProductForId/2011-10-01 API call; quota=20 restore=20.00    Returns a list of products and their attributes, based on a list of Product IDs that you specify.
        Lists: IdList.Id Required: MarketplaceId+IdType+IdList

我无法弄清楚为什么会这样,我觉得这是我的某种语法问题,但似乎无法弄清楚该怎么做。在亚马逊MWS暂存器中它将请求详细信息显示为:

&IdType=UPC
&IdList.Id.1=013138304582 HTTP/1.1

我尝试将IdList更改为IdList.Id和IdList.Id.1 - 但这只是在Python中给出了语法错误。我确信这对于有经验的人来说是一个简单的解决方案。非常感谢任何和所有帮助。

1 个答案:

答案 0 :(得分:2)

IdList类型为list,而非str

response = mws.get_matching_product_for_id(MarketplaceId=marketplaceId,IdType="UPC",IdList=["013138304582"])