yoavaviram / python-amazon-simple-product-api

A simple Python wrapper for the Amazon.com Product Advertising API ⛺
Apache License 2.0
815 stars 212 forks source link

400 request error with provided example #110

Closed Karlheinzniebuhr closed 7 years ago

Karlheinzniebuhr commented 7 years ago

After running the sample commands provided in the documentation, `from amazon.api import AmazonAPI

amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)

product = amazon.lookup(ItemId='B00EOE0WKQ')`

I'm getting this error:

product = amazon.lookup(ItemId='B00EOE0WKQ') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/site-packages/amazon/api.py", line 174, in lookup response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs) File "/usr/local/lib/python2.7/site-packages/bottlenose/api.py", line 265, in __call__ {'api_url': api_url, 'cache_url': cache_url}) File "/usr/local/lib/python2.7/site-packages/bottlenose/api.py", line 226, in _call_api return urllib2.urlopen(api_request, timeout=self.Timeout) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 435, in open response = meth(req, response) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 548, in http_response 'http', request, response, code, msg, hdrs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 473, in error return self._call_chain(*args) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 556, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request

I have the latest python 2.9.13 and all packages with the latest versions also.

Karlheinzniebuhr commented 7 years ago

Ok so I had to activate my api key for the product api, it's weird that this step is not included in the api registering process but anyway, that solved the problem

AminSarafraz commented 7 years ago

I have spent few hours to figure out how to "activate my api key for the product api" but no success. Would you please give more information on what I have to do. Apparently the preferred way is to create an IAM user, which I have done, but I'm not sure what kind of policy I need to assign to this new user. I have tried several policies but no luck so far. Any help is appreciated.

Karlheinzniebuhr commented 7 years ago

Just open this link and follow the registration steps, after doing that my API Key started working fine