Votre exemple fonctionne tel quel, à l’exception des paramètres attendus sur notre site de test :
○ → curl -i -X PUT "https://try.discourse.org/admin/users/41/suspend.json" \
-H "Api-Key: swordfish" \
-H "Api-Username: michael" \
-H "Content-Type: application/json" \
-d '{"suspend_until": "2024-12-31", "reason": "Violation of community guidelines"}'
HTTP/2 200
server: nginx
date: Mon, 11 Nov 2024 19:27:44 GMT
content-type: application/json; charset=utf-8
vary: Accept-Encoding
x-frame-options: SAMEORIGIN
x-xss-protection: 0
x-content-type-options: nosniff
x-permitted-cross-domain-policies: none
referrer-policy: strict-origin-when-cross-origin
x-discourse-username: michael
x-discourse-route: users/suspend
cache-control: no-cache, no-store
x-request-id: fe9c5ddc-b11a-45ba-ab41-9403eb53f255
cdck-proxy-id: app-router-tiehunter03.sea1
strict-transport-security: max-age=31536000
cdck-proxy-id: app-balancer-tieinterceptor1b.sea1
{
"suspension": {
"suspend_reason": "Violation of community guidelines",
"full_suspend_reason": "Violation of community guidelines",
"suspended_till": "2024-12-31T00:00:00.000Z",
"suspended_at": "2024-11-11T19:27:44.927Z",
"suspended_by": {
"id": 85,
"username": "michael",
"name": "Michael Brown",
"avatar_template": "/user_avatar/try.discourse.org/michael/{size}/639_2.png"
}
}
}
- Valider la clé API
Discourse affiche-t-il un utilisateur authentifié valide (x-discourse-username) lors d’une simple requête GET avec cette clé ? - Valider l’ID utilisateur
il existe vraiment, n’est-ce pas ? Il renverra une erreur 404 s’il n’existe pas. - Êtes-vous derrière Cloudflare ?
Cela peut perturber les paramètres.