python - 亚马逊 MWS Boto get_matching_product_for_id

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

我是 Python 和 Boto 的新手。我已使用 boto 成功连接并检索结果

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

我已在 Amazon 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 语法错误。我确信这对于有经验的人来说是一个简单的修复。非常感谢任何和所有的帮助。

最佳答案

IdListlist 类型,而不是 str:

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

关于python - 亚马逊 MWS Boto get_matching_product_for_id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31290284/

相关文章:

python - 用额外的值更新字典

c# - ECR 镜像 .NET 6 不同的 CloudWatch 日志格式

java - AWS Lambda Java/Kotlin 向 SQS 发送消息

amazon-web-services - 必须在构建器或设置环境中提供显式区域以提供区域

python - python字符串的Golang JSON解码

python - boto s3 - 使用数组写入一个 csv 文件

python - 使用 boto 将公共(public) URL 上可用的图像上传到 S3

python - 如果结果为 True,如何获得绿色矩形;如果 result = (paper == dict_k) 中结果为 False,如何获得红色框?

python - 为什么双分号是 Python 中的 SyntaxError?

python - 如何使用 python pandas 对分割文本进行分组并计算其数量?