I am trying to make a http request using Python3.8.5 + requests 2.25.0. The request contains Authorization Token in the header.
When use Postman to make the request, I can get response without issue. But, when I use following python code to make the request, it returns 401. Not sure what is worng in the code.
401 {"detail":"Authentication credentials were not provided."}
Following are the python code having issues.
import requests
url = <MY_URL>
payload={}
headers = {
'Authorization': 'TOKEN <MY_TOKEN>'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
The problem resloved by adding a / at the end of the request url. :-)