Skip to content Skip to sidebar Skip to footer

Python Requests Http Response 406

I have my own domain where an json file is stored (http://example.com/file.json). When accesing the file in browser using the direct link, the json is returned just fine. But when

Solution 1:

Solved by using a different User-Agent. The default Python User-Agent 'python-requests/2.21.0' was being probably blocked by the hosting company.

r = requests.get(url, headers={"User-Agent": "XY"})

Some of the possible agents: List of User Agent strings

Solution 2:

Your own accepted answer is most likely incorrect. This error means the value of Accept header does not match Content-Type of the response. If you'd send Accept: */* , it would work (at least the 406 would not be returned).

Post a Comment for "Python Requests Http Response 406"