I need to send data with json with a request in Python.
Python version: 2.7.6
OS: Ubuntu 16.04
For instance:
import json
import requests
f = requests.Session()
data = {
"from_date": "{}".format(from_date),
"to_date": "{}".format(to_date),
"Action": "Search"
}
get_data = f.post(URL, json=data, timeout=30, verify=False)
But after running this code, show this error:
get_data = f.post(URL, json=data, timeout=30, verify=False)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 497, in post
return self.request('POST', url, data=data, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'
How to solve this problem?
mySun source
share