自分の開発者フォーラムにPythonリクエストを送信しようとすると、ステータスコード 401 が返されます。認証情報はすべて正しい(と思っている)のですが、なぜこのようなことが起こるのでしょうか?
import requests
url = "https://bookish-garbanzo-x5wxpxv7xp96396wp-4200.app.github.dev/posts.json"
# リクエストのヘッダー
headers = {
"Api-Key": "************************************************************",
"Api-Username": "NateDhaliwal",
"Content-Type": "application/json"
}
# リクエストで送信されるフォームデータ
payload = {
"title": "This topic was made using the API",
"raw": "Hello there, this **topic** was made using the API!",
"category": 6
}
# ヘッダーとフォームデータを使用してPOSTリクエストを実行
response = requests.post(url, headers=headers, json=payload)
# レスポンスのステータスとテキストを出力
print("Status Code:", response.status_code)
print("Response Body:", response.text)