What is the request header by default in python requests

Question:

I am using requests to POST my data to a URL. I need to know what is the header that is sending by my request?

import requests
conf_json = {"key_1": "value_1", "key_2": "value_2"}                    
r = requests.post(API_URL, json=conf_json)

I can get response header by r.headers, but I need request header and I don’t know how I should get it. can you please guide me?

Asked By: Reza Amya

||

Answers:

import requests
conf_json = {"key_1": "value_1", "key_2": "value_2"}                    
r = requests.post(API_URL, json=conf_json)

# get request headers
print(r.request.headers)
Answered By: iammehrabalam
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.