fbpbdmin
(deepblue)
1
Vorrei cambiare il timestamp di un argomento, ho trovato questa API
Nel frattempo, ha riscontrato un errore con “Bad CSRF”, qualcuno potrebbe darmi un suggerimento? grazie
import requests
# intestazioni errate
headers = {
"Authorization": f"Apikey {api_key}",
"User-Agent": api_username
}
# corretto
headers = {"Content-Type": "application/json; charset=utf-8", "Api-Key": api_key, "Api-Username": api_username }
# Modifica la data di creazione
created_at = "1701417600"
update_data = {"timestamp": created_at}
response = requests.put(f"https://www.mysite.com/t/6532/change-timestamp.json", json=update_data, headers=headers)
print(response.status_code) # 403
print(response.text) # '["BAD CSRF"]'
print(response.json()) # ['BAD CSRF']
Firepup650
(Firepup Sixfifty)
2
Queste non sono le intestazioni giuste:
Una volta ottenuta la tua API Key, puoi passarla insieme al tuo API Username come intestazione HTTP in questo modo:
curl -X GET "http://127.0.0.1:3000/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"
e questo è come appariranno le richieste POST:
curl -X POST "http://127.0.0.1:3000/categories" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system" \
-F "name=89853c20-4409-e91a-a8ea-f6cdff96aaaa" \
-F "color=49d9e9" \
-F "text_color=f0fcfd"
2 Mi Piace
fbpbdmin
(deepblue)
3
Grazie @Firepup650
colpa mia, sì, quelle sono le intestazioni errate, ho pubblicato quelle corrette sopra, funziona.
1 Mi Piace
system
(system)
Chiuso
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.