Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,12 @@ use the same key::
},
...
}
>>> r1.text == r2.text
>>> r1.json()['form'] == r2.json()['form']
True

The complete response text may differ between requests (for example, due to
headers added by ``httpbin``), but the form payload is equivalent.

There are times that you may want to send data that is not form-encoded. If
you pass in a ``string`` instead of a ``dict``, that data will be posted directly.

Expand Down Expand Up @@ -399,6 +402,20 @@ But, since our ``status_code`` for ``r`` was ``200``, when we call
>>> r.raise_for_status()
None

For complete status/error handling in one example::

>>> import requests
>>> from requests.exceptions import HTTPError
>>> try:
... response = requests.get('https://api.github.com')
... response.raise_for_status()
... except HTTPError as http_err:
... print(f'HTTP error occurred: {http_err}')
... except Exception as err:
... print(f'Other error occurred: {err}')
... else:
... print('Success!')

All is well.


Expand Down