Today I was playing with some post data in python, however when trying to set custom headers using the python-requests library and setting the custom headers, it still sends it's default headers, not my custom ones.
headers={'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/3.5.0',
}
response = requests.post(url,headers,postdata)
What appears while inspecting the data with fiddler:
You seem to have an error in your call to the requests.post function. The correct call could look like this:
requests.post(url,headers=headers,data=postdata)
Changing this in the code you provided should result in requests sending your custom headers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.