طلب Python إلى المنتدى يستمر في الحصول على خطأ 401

عند محاولة إجراء طلب 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)

هل تقوم بالتشغيل في GitHub Codespaces؟ إذا كنت ترغب في الوصول إلى هذا النطاق خارج متصفح مصادق عليه، فستحتاج إلى جعله عامًا. مزيد من المعلومات هنا: Security in GitHub Codespaces - GitHub Docs

3 إعجابات

لقد نجح ذلك، شكراً لك!

إعجاب واحد (1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.