Mar-11-2021, 09:40 PM
I am trying to use the requests library to hit some endpoints, but I am having problems passing the auth token. This curl works just fine:
I have tried so many things from stackoverflow but nothing has worked. I am at the point of just using curl but wanted to see if anybody here has had any similar experience.
Thanks for your time,
Output:curl -X POST "https://my/api/" -H "accept: application/json" -H "Authorization: eeJ0eXAiOiJKV1.eyzdWIiOiIyNDAxN2QxMDdjODA0ZmI4.jArOH9fvXGiblidZ1ZhxvjLvc1Bg_AGDd" -H "Content-Type: application/json" -d "{ \"language\": \"en\", \"name\": \"dude\", \"password\": \"mypw\"}"
but when I try with requests:token = 'eeJ0eXAiOiJKV1.eyzdWIiOiIyNDAxN2QxMDdjODA0ZmI4.jArOH9fvXGiblidZ1ZhxvjLvc1Bg_AGDd' payload = {'language': 'en', 'name': 'dude', 'password': 'mypw'} r = requests.post("https://my/api/", headers={'Authorization':token}, data=payload)I get a 500 from the server or if I change 'Authorization' to 'auth_token' or something else, I get unrecognized token.
I have tried so many things from stackoverflow but nothing has worked. I am at the point of just using curl but wanted to see if anybody here has had any similar experience.
Thanks for your time,