I have been doing this for most of the day, but I have encountered the same 400 error for quite some time. The main purpose of the application is to parse the ISBN book from the Amazon URL referral and use it as a reference key to extract images from the Amazon product advertising API . The webpage is written in Python 3.4 and Django 1.8. I spent a lot of time researching here and decided to use python-amazon-simple-product-api, as it would make it a little easier to analyze Amazon results.
Answers: How to use the Python Amazon Simple Product API to get product pricing
Make it pretty simple, but I haven't got it yet to find the product successfully. Here is a console listing of what my method usually does, with ISBN populated correctly:
>>> from amazon.api import AmazonAPI >>> access_key='amazon-access-key' >>> secret ='amazon-secret-key' >>> assoc ='amazon-associate-account-name' >>> amazon = AmazonAPI(access_key, secret, assoc) >>> product = amazon.lookup(ItemId='1632360705') Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/tsuko/.virtualenvs/django17/lib/python3.4/site-packages/amazon/api.py", line 161, in lo okup response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs) File "/home/tsuko/.virtualenvs/django17/lib/python3.4/site-packages/bottlenose/api.py", line 242, i n __call__ {'api_url': api_url, 'cache_url': cache_url}) File "/home/tsuko/.virtualenvs/django17/lib/python3.4/site-packages/bottlenose/api.py", line 203, i n _call_api return urllib2.urlopen(api_request, timeout=self.Timeout) File "/usr/lib/python3.4/urllib/request.py", line 153, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python3.4/urllib/request.py", line 461, in open response = meth(req, response) File "/usr/lib/python3.4/urllib/request.py", line 571, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.4/urllib/request.py", line 499, in error return self._call_chain(*args) File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain result = func(*args) File "/usr/lib/python3.4/urllib/request.py", line 579, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request
Now I think I'm wondering if this is some kind of quirk with PythonAnywhere or if I skipped the configuration setting in Django? As far as I can tell through AWS and the Amazon Associates page, my keys are correct. I'm not too worried about parsing at the moment, just getting the object. I even tried to get around the API and just use Bottlenose (which extends the API), but I get the same 400 error result.
I'm really new to the Django and Amazon APIs, any help would be appreciated!