Home > OS >  Curl command works fine, while Python requests returns 404
Curl command works fine, while Python requests returns 404

Time:10-10

Curl

curl "https://api.wanikani.com/v2/summary" \ -H "Wanikani-Revision: 20170710" \ -H "Authorization: Bearer <API-KEY>"

This command returns the expected json.

Python code

import requests

headers = {"Wanikani-Revision": "20170710", "Authorization": "Bearer <API-KEY>"}
res = requests.post('https://api.wanikani.com/v2/summary', headers = headers)

print(res.text)

This code returs 404. {"error":"Not found","code":404}

CodePudding user response:

That function only accepts GET. Look https://docs.api.wanikani.com/20170710/#summary

Try:

import requests

headers = {"Wanikani-Revision": "20170710", "Authorization": "Bearer <API-KEY>"}
 
res = requests.get('https://api.wanikani.com/v2/summary', headers = headers)

print(res.text)
  • Related