Updating topic body via the API

I’m trying to update a topic body via the API, but I’m not sure how to do it.

I tried to use POST /posts/ and providing it with the topic_id which only creates a new post for a topic.

I also tried PUT /posts/:id but providing it with the topic id doesn’t update the topic. I actually get a 403.

PUT /t/:slug/:id doesn’t seem to be what I’m looking for.

Any advice here, please?

The official docs say it’s a PUT for /posts/:id with post[raw] in FormData:

Where :id is equal to the topic ID in this case?

No, it’s the post id.

On Discourse land, a topic it’s just a bunch of posts. A topic has no body, the first post of the topic is the body.


How do I get the first post of the topic?

Got it. http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1t~1{id}.json%2Fget

It really depends on how you are managing stuff.

If it’s a sync, you can save the post id of the topic when you create it, so it’s easy when you need to update it later (if that’s a common operation).


EDIT: never mind!.. that worked… i was missing the post[raw]… :confused:

Sorry to reopen an old thread. But I have been trying this for a couple of days now.

I have looked at the api and at some help docs as well (How can I update topic content using Discourse API? - Stack Overflow)
And I see the docs suggest to use: /posts/{postid}
but still cannot crack this post update scheme.

For example… looking at this topic page, the last post id from Rafael is 280744
But this
takes me to an error page… :confused:

So, how can one use this scheme?
I tried a multitude of variations without luck… :frowning:

4 posts were split to a new topic: How should I get the raw text of a single post