mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 14:50:16 +00:00
Documentation for multivalued form-encoded element as a list (#4700)
This commit is contained in:
@@ -261,6 +261,23 @@ useful when the form has multiple elements that use the same key::
|
||||
...
|
||||
}
|
||||
|
||||
An alternative method to express multiple elements with the same key is to use
|
||||
a dictionary and list the element values as a list::
|
||||
|
||||
>>> payload = {'key1': ['value1', 'value2']}
|
||||
>>> r = requests.post('http://httpbin.org/post', data=payload)
|
||||
>>> print(r.text)
|
||||
{
|
||||
...
|
||||
"form": {
|
||||
"key1": [
|
||||
"value1",
|
||||
"value2"
|
||||
]
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user