Amazon Simple Product API Error Finding Product

from amazon.api import AmazonAPI AMAZON_ACCESS_KEY = "A******************A" AMAZON_SECRET_KEY = "7***********************E" AMAZON_ASSOC_TAG = "j*****-20" amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG, region='US') print(amazon) #product = amazon.lookup(ItemId='B002RL8FBQ') 

When I run the code above, it works fine, and I get this output from the print function: <amazon.api.AmazonAPI object at 0x7fb6e59f7b38>

So, everything works fine with my passkey, secret key and associated tag.

However, if I comment on the last line #product = amazon.lookup(ItemId='B00EOE0WKQ') , I get this error trace:

 Traceback (most recent call last): File "test.py", line 8, in <module> product = amazon.lookup(ItemId='B00EOE0WKQ') File "/home/darren/Python_projects/amazon_wp/myvenv/lib/python3.4/site-packages/amazon/api.py", line 173, in lookup response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs) File "/home/darren/Python_projects/amazon_wp/myvenv/lib/python3.4/site-packages/bottlenose/api.py", line 251, in __call__ {'api_url': api_url, 'cache_url': cache_url}) File "/home/darren/Python_projects/amazon_wp/myvenv/lib/python3.4/site-packages/bottlenose/api.py", line 212, in _call_api return urllib2.urlopen(api_request, timeout=self.Timeout) File "/usr/lib/python3.4/urllib/request.py", line 161, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python3.4/urllib/request.py", line 469, in open response = meth(req, response) File "/usr/lib/python3.4/urllib/request.py", line 579, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.4/urllib/request.py", line 507, in error return self._call_chain(*args) File "/usr/lib/python3.4/urllib/request.py", line 441, in _call_chain result = func(*args) File "/usr/lib/python3.4/urllib/request.py", line 587, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request 

I followed the instructions from official github for this https://github.com/yoavaviram/python-amazon-simple-product-api , and the code that I use, you will see that I used from the subheading "Use" on the github page, so I'm not sure what is going wrong.

For more information, I use the virtual environment and show that I have the correct packages installed, this is my way out of the freeze:

 (myvenv) darren@my_comp:~/Python_projects/amazon_wp$ pip3 freeze bottlenose==0.6.3 lxml==3.6.0 python-amazon-simple-product-api==2.1.0 python-dateutil==2.5.3 six==1.10.0 

In addition, I have tried several different asin actual product numbers, and I am getting the same error message.

I am using python 3.4 on ubuntu 14.04

+8
python amazon-web-services
source share
2 answers

I think the problem is with the region. Select a valid value here . The explanation may be that AWS can verify your credentials, but when it comes to a β€œreal” call, it fails because β€œUS” is not a valid area ...

+3
source share

You may need to authorize your account to access the API . This step by step should go through it.

Edit:


I installed all the same versions and use the same python code with my own keys and it works fine. The only time I encountered this error was that I did not specify the area (which you explicitly do).

One thing I will try is to add the following code to my script:

import registration
logging.basicConfig (level = logging.DEBUG)

which should display the following request url:

DEBUG: bottlenose.api: Amazon URL: http://webservices.amazon.co.uk/onca/xml?AWSAccessKeyId= & AssociateTag = & ItemId = B00EOE0WKQ & Operation = ItemLookup & ResponseGroup = Large & S = e in AWSECommerceService & Mark = & Version = 2013-08-01 & Signature =

You can visit this in your browser and see the returned XML document. If it fails, it will hopefully give you a better error than pythonlib gives you.

For example, if I am https://associates-amazon.s3.amazonaws.com/scratchpad/index.html (never got this to work for me), but it contains a list of base URLs for the area.

I created my associated account in the .co.uk area, so my requests will only be valid for http://webservices.amazon.co.uk , if I try to request http://webservices.amazon.com instead, then I'll see:

The request signature we signed does not match your subscription provided. Verify the AWS passkey and signature method. consult service documentation for details.

If you have an associated account on amazon.com, try it without specifying a region, as I consider this a default. In addition to the above, make sure that your virtual machine has an Internet connection, and if nothing else works, try creating a different passkey and use it.

-one
source share

All Articles