عند محاولة إجراء طلب Python إلى منتدى التطوير الخاص بي، أحصل على رمز حالة 401. بيانات الاعتماد الخاصة بي صحيحة (أعتقد)، فلماذا يحدث هذا؟
import requests
url = "https://bookish-garbanzo-x5wxpxv7xp96396wp-4200.app.github.dev/posts.json"
# Headers for the request
headers = {
"Api-Key": "************************************************************",
"Api-Username": "NateDhaliwal",
"Content-Type": "application/json"
}
# Form data to be sent in the request
payload = {
"title": "This topic was made using the API",
"raw": "Hello there, this **topic** was made using the API!",
"category": 6
}
# Make the POST request with headers and form data
response = requests.post(url, headers=headers, json=payload)
# Print response status and text
print("Status Code:", response.status_code)
print("Response Body:", response.text)