Convert CURL Post to Python Requests Failing
If you are using one of the latest versions of requests:Try using the 'json' kwarg (no need to convert to json explicitly) instead of the 'data' kwarg:
response = requests.post(url, json=data, headers=headers)
Note: Also, this way you can omit the 'Content-type' header.
In case you have a proxy configured at your environment, define it at your session/request as well.
For example with session:
my_proxies = { 'http': 'http://myproxy:8080', 'https': 'https://myproxy:8080' } session = requests.Session() request = requests.Request('POST', 'http://my.domain.com', data=params_template, headers=req_headers, proxies=my_proxies) prepped = session.prepare_request(request) response = session.send(prepped)
see documentation:
request http://docs.python-requests.org/en/master/user/quickstart/
session http://docs.python-requests.org/en/master/user/advanced/