Python requests library returns 401 Unauthorized when calling my API
posée 3 days ago7 vuesen
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
Environnement :Python 3.12Windows 11
🤖 Diagnostic IA
Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.
posée 3 days ago
Jean Pierre 1.7k
Aucune réponse
Sign in and verify your email to post an answer.