API を使用して投稿の内容を更新する際に 500 または 400 エラーが発生

API を使って投稿の内容を更新しようとしています。Discourse API Docs のドキュメントによると、PUT /posts/:id.jsonpost[raw] をボディとして送信する必要があると記載されています。

しかし、これを実行すると 400 エラーと共に以下のメッセージが表示されます。

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

このエラーは post というパラメータが不足している、または値が空であると指摘していますが、HTTP リクエストで post[raw]post に置き換えると、500 Internal Server Error が返されます。

投稿の内容は単に「Edited comment」だったため、内容自体に問題があるとは思えません。

何か見落としているのでしょうか?それとも API ドキュメントが古くなっているのでしょうか?

私は https://forums.balena.io でクラウドインスタンスを運用していますが、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.