Python RequestsPython

Python-Programme
Anonymous
 Python Requests

Post by Anonymous »

Integriere ich in eine Versand-API von Drittanbietern. Wenn ich eine Postanforderung an ihren/api/login-plugin -Dendpunkt mit postman sende, funktioniert es perfekt und gibt eine 200-OK-Antwort zurück. class = "Lang-json PrettyPrint-Override">

Code: Select all

{
"status": false,
"code": 401,
"message": "The authorization key is invalid"
}
< /code>

 ✅ Was funktioniert in Postman: < /h3>
[b] URL: < /strong>

https://demo.stage.torod.co/en/api/login-plugin

Header: [/b]

Code: Select all

Content-Type: application/json
KEY: [masked_key]
Körper (JSON):

Code: Select all

{
"email": "[user_email]",
"password": "[user_password]",
"plugin": "magento",
"webhook_url": "",
"site_name": "odoo",
"site_url": "http://localhost:8069"
}
< /code>

 ❌ Was in Python fällt: < /h3>
import requests

headers = {
"KEY": "[masked_key]",
"Content-Type": "application/json"
}

payload = {
"email": "[user_email]",
"password": "[user_password]",
"plugin": "magento",
"webhook_url": "",
"site_name": "odoo",
"site_url": "http://localhost:8069"
}

response = requests.post("https://demo.stage.torod.co/en/api/login-plugin", headers=headers, json=payload)

print(response.status_code)
print(response.text)
Was ich ausprobiert habe:

[*] Header und Nutzlast übereinstimmen postman genau. Header.
Curl funktioniert auch von derselben Maschine. /> danke! Ich habe eine 200 -OK -Antwort wie im Postman erwartet, aber ich bekomme konsequent einen 401 nicht autorisierten Fehler. Ich habe die Header, die Nutzlast verifiziert und sogar versucht, den Benutzeragenten nachzuahmen.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • Für Python, was bedeutet es für
    by Anonymous » » in Python
    0 Replies
    31 Views
    Last post by Anonymous
  • Python Requests
    by Anonymous » » in Python
    0 Replies
    17 Views
    Last post by Anonymous
  • Holen Sie sich alle Daten von der API in einem einzigen Treffer – Python-Requests
    by Anonymous » » in Python
    0 Replies
    5 Views
    Last post by Anonymous
  • Warum löst dies „requests.Exceptions.HTTPError“ aus?
    by Guest » » in HTML
    0 Replies
    49 Views
    Last post by Guest
  • „requests.get Missing Schema Unvalid URL“-Fehler
    by Anonymous » » in Python
    0 Replies
    3 Views
    Last post by Anonymous