Skip to content
Myr

fix #3902 Add proposed documentation change for post data

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Gary Wu · committed by Gary Wu · parent 3f3df8b · Browse files · 2 files+41 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+41 added−2 removed

  • other:+41 added−2 removed

2 files+41 added−2 removed

modified:docs/user/quickstart.rst+40 added-1 removed
232 unmodified lines
233 },234 ...235 }236237You can also pass a list of tuples to the ``data`` argument. This is particularly238useful when the form has multiple elements that use the same key::239240 >>> payload = (('key1', 'value1'), ('key1', 'value2'))241 >>> r = requests.post('http://httpbin.org/post', data=payload)242 >>> print(r.text)243 {244 ...245 "form": {246 "key1": [247 "value1",248 "value2"249 ]250 },251 ...252 }253254Value of each payload element can be a scalar or an iterable::255256 >>> payload = (('key1', ('value1', 1, (1, 2))), {'key2', ('value2', 2)})257 >>> r = requests.post('http://httpbin.org/post', data=payload)258 >>> print(r.text)259 {260 ...261 "form": {262 "key1": [263 "value1",264 "1",265 "1",266 "2"267 ],268 "key2": [269 "value2",270 "2"271 ]272 },273 ...274 }275276There are many times that you want to send data that is not form-encoded. If277you pass in a ``string`` instead of a ``dict``, that data will be posted directly.278279For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::
243 unmodified lines
523Timeouts524--------525526You can tell Requests to stop waiting for a response after a given number of488seconds with the ``timeout`` parameter. Nearly all production code should use 527seconds with the ``timeout`` parameter. Nearly all production code should use528this parameter in nearly all requests. Failure to do so can cause your program529to hang indefinitely::530531 >>> requests.get('http://github.com', timeout=0.001)
36 unmodified lines
modified:AUTHORS.rst+1 added-1 removed
177 unmodified lines
178- Moinuddin Quadri <moin18@gmail.com> (`@moin18 <https://github.com/moin18>`_)179- Matt Kohl (`@mattkohl <https://github.com/mattkohl>`_)180- Jonathan Vanasco (`@jvanasco <https://github.com/jvanasco>`_)181- David Fontenot (`@davidfontenot <https://github.com/davidfontenot>`_)182182- Gary Wu (`@garywu <https://github.com/garywu>`_)