I need to send data as json with requests module in Python.
For example:
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 run this code, it showed 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'
I'm on Ubuntu 16.04
and my Python version is 2.7.6
How to issue this problem?