mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #2724 from smiley/master
Add documentation in "More complicated POST requests" (Quickstart) to resolve #2686
This commit is contained in:
@@ -228,6 +228,15 @@ For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::
|
||||
>>> payload = {'some': 'data'}
|
||||
|
||||
>>> r = requests.post(url, data=json.dumps(payload))
|
||||
|
||||
Instead of encoding the ``dict`` yourself, you can also pass it directly using
|
||||
the ``json`` parameter (added in version 2.4.2) and it will be encoded automatically:
|
||||
|
||||
>>> import json
|
||||
>>> url = 'https://api.github.com/some/endpoint'
|
||||
>>> payload = {'some': 'data'}
|
||||
|
||||
>>> r = requests.post(url, json=payload)
|
||||
|
||||
|
||||
POST a Multipart-Encoded File
|
||||
|
||||
Reference in New Issue
Block a user