Python send request with header

32 views Asked by At

Sending Post request error

Hi talented developers. I am going to send request to specified url with authorization header. I am trying to send POST request to POST https://server/api HTTP 1.1 Authorization: Bearer a12b34567c89012def34g56789hi0j12 { "data" : "test" }

url = "https://server/api"
headers = {'Authorization' : 'Bearer %s' % API_KEY}
data = {
    "data" : "test"
}
req = requests.post (url, headers = headers, data = 
json.dumps(data))

Could you tell me what I am doing wrong in this code snippet? I appreciate your help. Thanks

0

There are 0 answers