Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add helpful error message to r.json() method #1296

merged 3 commits into from

5 participants


It took me a while to figure out that this error was coming from the newest version of Requests rather than somewhere in Django. This updates the documentation to be more control-F friendly.


+1. I'm always in favour of better documentation.


I'm not sure this is the only error the json module raises but I'm generally +1 for this.


Good point @sigmavirus24. Fixed my wording.


Thanks very much. :+1: I was going to look to see if json.decode raised more than a ValueError but I'm too busy with school work so this is a good starting point. I also had plans of digging deep into the docs and checking the validity of them. In particular the hooks documentation, so if you'd like you're more than welcome to attack that too. :)


:sparkles: :cake: :sparkles:

@kennethreitz kennethreitz merged commit 5b937b3 into kennethreitz:master

1 check passed

Details default The Travis build passed

This is only true if the 401 response is not content-aware; there's no fundamental link between the status code and the content type of the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 docs/user/quickstart.rst
4 docs/user/quickstart.rst
@@ -131,7 +131,9 @@ There's also a builtin JSON decoder, in case you're dealing with JSON data::
>>> r.json()
[{u'repository': {u'open_issues': 0, u'url': '
-In case the JSON decoding fails, ``r.json`` raises an exception.
+In case the JSON decoding fails, ``r.json`` raises an exception. For example, if
+the response gets a 401 (Unauthorized), attempting ``r.json`` raises ``ValueError:
+No JSON object could be decoded``
Raw Response Content
Something went wrong with that request. Please try again.