Reputation: 27397
I have tried to use PUT /t/:id
to update topic content with no effect.
https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/topics.rb
Seems there is no way to update the content using API. Am I missing anything?
Upvotes: 4
Views: 1499
Reputation: 8027
You need to provide the topic slug like this: PUT /t/:slug/:id
as documented here: http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1t~1%7Bslug%7D~1%7Bid%7D.json%2Fput
The /t/:id
endpoint only works if you issue a GET
request as documented here: http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1t~1%7Bid%7D.json%2Fget which I guess is not what you want.
The solution
In 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.
So, what you do is this:
GET /t/:id
with your topic idpost_stream
and get the first post, or whichever you need. Get the IDPUT /posts/:id
and use the ID you just got, and provide post[raw]
in the body.Please, see this discussion: https://meta.discourse.org/t/updating-topic-body-via-the-api/61220/5
Upvotes: 5