500 ou 400 lors de la mise à jour du contenu d'un post via l'API

Je tente de mettre à jour le contenu d’un article en utilisant l’API. La documentation à l’adresse Discourse API Docs indique que je dois utiliser PUT /posts/:id.json en envoyant post[raw] dans le corps de la requête.

Cela entraîne une erreur 400 accompagnée du message suivant :

errors: [ 'param is missing or the value is empty: post' ]

L’erreur se plaint d’un paramètre nommé post, mais remplacer post[raw] par post dans ma requête HTTP entraîne une réponse 500 Internal Server Error.

Le contenu de l’article était simplement Commentaire édité, donc je ne pense pas que cela soit lié au contenu.

Est-ce que j’oublie quelque chose ? La documentation de l’API est-elle obsolète ?

J’exécute une instance cloud à l’adresse https://forums.balena.io. Je ne connais pas la version de Discourse.

I just realised I was passing a topic id instead of a post id to the API, but the problem still persists. I’m trying to update post 34816, assuming you have access to the cloud instance:

PUT https://forums.balena.io/posts/34816.json

With body:

{
    "post": "Edited comment"
}

And that still results in 500.

Why is my post being flagged as spam? Is this not the right place to submit bugs?

Turns out it works fine if I pass raw instead of post in the request body. The docs could probably be clearer about that :slight_smile:

Glad you got it figured out! I’ve got a bunch of topics that are me taking to myself.

Mostly these are the docs, and they are continually updated: How to reverse engineer the Discourse API :wink:

I generally forget that there are any docs besides just seeing how it works in the browser development tools.