Python requests library returns 401 Unauthorized when calling my API
poze 2 days ago6 gadeen
0
The API works successfully in Postman, but the same request from Python returns 401 Unauthorized. I am passing the bearer token in the request headers.
import requests
url = "https://api.example.com/customers"
headers = { "Authorization": "Bearer my-token", "Content-Type": "application/json" }
response = requests.get(url, headers=headers)
print(response.status_code) print(response.text)
=================================================================== Error 401 Unauthorized
Anviwònman:Python 3.12Windows 11
🤖 Dyagnostik IA
Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.
poze 2 days ago
Jean Pierre 1.7k
Pa gen repons
Sign in and verify your email to post an answer.