Skip to content

Commit ab38e2c

Browse files
authored
Make the data vs json parameters more clear (#5382)
As https://stackoverflow.com/q/26685248/2693875 question and answer popularity shows that there is a lot of people who do not understand the distinction.
1 parent 77d1e9a commit ab38e2c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/user/quickstart.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,12 @@ For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::
283283

284284
>>> r = requests.post(url, data=json.dumps(payload))
285285

286-
Instead of encoding the ``dict`` yourself, you can also pass it directly using
287-
the ``json`` parameter (added in version 2.4.2) and it will be encoded automatically::
286+
Please note that the above code will NOT add the ``Content-Type`` header
287+
(so in particular it will NOT set it to ``application/json``).
288+
289+
If you need that header set and you don't want to encode the ``dict`` yourself,
290+
you can also pass it directly using the ``json`` parameter (added in version 2.4.2)
291+
and it will be encoded automatically:
288292

289293
>>> url = 'https://api.github.com/some/endpoint'
290294
>>> payload = {'some': 'data'}
@@ -293,8 +297,6 @@ the ``json`` parameter (added in version 2.4.2) and it will be encoded automatic
293297

294298
Note, the ``json`` parameter is ignored if either ``data`` or ``files`` is passed.
295299

296-
Using the ``json`` parameter in the request will change the ``Content-Type`` in the header to ``application/json``.
297-
298300
POST a Multipart-Encoded File
299301
-----------------------------
300302

0 commit comments

Comments
 (0)