summaryrefslogtreecommitdiff
path: root/requests/api.py
diff options
context:
space:
mode:
authorCarol Willing <carolcode@willingconsulting.com>2014-07-17 12:34:31 -0700
committerCarol Willing <carolcode@willingconsulting.com>2014-08-28 12:53:19 -0700
commit8f17741849edb5e7eba0356f90cb17e43c938a2f (patch)
tree1d16bc49a8d30fb62a1162fd625417486286a4b9 /requests/api.py
parentd22b8d8e7e8fcb8d16efba6841977dc81ac2c935 (diff)
downloadpython-requests-8f17741849edb5e7eba0356f90cb17e43c938a2f.tar.gz
Adds json parameter for POST requests
Diffstat (limited to 'requests/api.py')
-rw-r--r--requests/api.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/requests/api.py b/requests/api.py
index 01d853d5..88db7dc7 100644
--- a/requests/api.py
+++ b/requests/api.py
@@ -22,6 +22,7 @@ def request(method, url, **kwargs):
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
+ :param json: (optional) json data to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of 'name': file-like-objects (or {'name': ('filename', fileobj)}) for multipart encoding upload.
@@ -77,15 +78,16 @@ def head(url, **kwargs):
return request('head', url, **kwargs)
-def post(url, data=None, **kwargs):
+def post(url, data=None, json=None, **kwargs):
"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
+ :param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
"""
- return request('post', url, data=data, **kwargs)
+ return request('post', url, data=data, json=json, **kwargs)
def put(url, data=None, **kwargs):