lionheart / bottlenose

A Python wrapper for the Amazon Product Advertising API.
Apache License 2.0
577 stars 112 forks source link

400 error #46

Closed daxeel closed 7 years ago

daxeel commented 8 years ago
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/bottlenose/api.py", line 251, in __call__
    {'api_url': api_url, 'cache_url': cache_url})
  File "/Library/Python/2.7/site-packages/bottlenose/api.py", line 212, in _call_api
    return urllib2.urlopen(api_request, timeout=self.Timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
MoorsTech commented 8 years ago

Got the same issue. Using Python 2.7.9 on ubuntu 14.04

dlo commented 8 years ago

Could one you guys post the full URL being POSTed to?

MoorsTech commented 8 years ago

[http://webservices.amazon.com/onca/xml?AWSAccessKeyId=[THEKEY]&AssociateTag=[THE TAG]&Keywords=Kindle%203G&Operation=ItemSearch&SearchIndex=All&Service=AWSECommerceService&Timestamp=2016-07-13T15%3A44%3A22Z&Version=2013-08-01&Signature=[SIGNATURE]%3D](http://webservices.amazon.com/onca/xml?AWSAccessKeyId=[THEKEY]&AssociateTag=[THE TAG]&Keywords=Kindle%203G&Operation=ItemSearch&SearchIndex=All&Service=AWSECommerceService&Timestamp=2016-07-13T15%3A44%3A22Z&Version=2013-08-01&Signature=[SIGNATURE]%3D)

Turns out, it works for the DE and CN marketplaces/endpoints. I tried CA, CN, DE, ES, FR, IN, IT, JP, UK, and US, none of them worked except DE and CN. Lucky for me, I happen to need DE but this strikes me as super weird. Might this have something to do with the change of version-reference a few days ago? The constructed URL for the DE-Endpoint is (apart from the TLD) identical btw.

MoorsTech commented 8 years ago

Ah, fack, stupid... Didn't realize I need to specifically have access to other marketplaces. The only bug here is that this type of error should be handled properly/transparently.

dlo commented 8 years ago

Aha! So that's the issue. We need a better error message. If you write it up I'll merge immediately. Thanks.

MoorsTech commented 8 years ago

Prolly not gonna get around to it before the weekend, but will do.

inesafmartins commented 8 years ago

@dlo and @MoorsTech I can confirm that is related to https://forums.aws.amazon.com/thread.jspa?threadID=238652&tstart=0 ?

GabrielRF commented 7 years ago

Since Dec 17 I'm getting Error 400. I'm using the exact some code for months. Is anyone else having the same issue? I've tried to change my keys and nothing worked yet..

---------- UPDATE ----------

Problem fixed. It was the system clock that was wrong. Now everything is running fine again.

transfluxus commented 7 years ago

I'm trying all kinds of regions and still get a 400 only. Does it matter where i registered my affiliate-program... on .com not .de or anything? I'm in germany tho...

GabrielRF commented 7 years ago

@transfluxus I suggest you to try this first: http://webservices.amazon.com/scratchpad/index.html There you will be able to know if the problem is on your code/server or on Amazon configuration.

D-Hastie commented 7 years ago

I have run into a strange issue with 400 errors. I run the same script from a mac and one from a Raspberry Pi. For some reason the raspberry pi will give HTTPError 400: bad request, whereas the mac one will run perfectly fine. I also used scratchpad to check the request, it worked fine there. File "SimpleTest.py", line 37, in <module> response = amazon.ItemLookup(ItemId='0521663962', ResponseGroup="Large") File "/usr/local/lib/python2.7/dist-packages/bottlenose/api.py", line 265, in __call__ {'api_url': api_url, 'cache_url': cache_url}) File "/usr/local/lib/python2.7/dist-packages/bottlenose/api.py", line 226, in _call_api return urllib2.urlopen(api_request, timeout=self.Timeout) File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 437, in open response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 550, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/urllib2.py", line 475, in error return self._call_chain(*args) File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request

The Pi used to work fine, but for the past month it hasn't.

EDIT: Nevermind. Check your time stamps people. Somehow my rasp-pi had the wrong time.

dlo commented 7 years ago

I've created a "bottlenose" tag on Stack Overflow and encourage anyone running into usage-related questions there instead of here on the issue tracker. Please only open a new issue if you find a bug or have a feature request. Thanks! ✨