Delete Post from a Topic Using discourse API

Is it possible to delete post from a Topic using Discourse API?

Corresponding user can only delete their POST.

Yes, if you can do it with the UI, you can do it via the API call. See the howto topic here titled “How to reverse engineer the Discourse API” for details.

1 Like

@User143 Review this topic:

and and this text file specifically

https://github.com/discourse/discourse_api/blob/master/routes.txt#L71-L78

3 Likes

I reviewed with this topic but i need to delete particular post from a topic.

I just tried with the following HTTP post but its not working

http://discourse.url.com/posts/1314/destroy_many/?api_key=test_beabcf136e&api_username=test_name

For delete we need to use this URL.Is it right?

destroy_many_posts DELETE /posts/destroy_many(.:format)

I don’t have any clear picture about this API URL. Can you please give the example for deleting the post

When I delete post from chrome using the delete button. I am getting the following header from chrome but i don’t know how can i call this DELETE post API

Remote Address:120.80.217.8:80
Request URL:http://discourse.url.com/posts/1314
Request Method:DELETE
Status Code:200 OK

Look at it the info from Chrome again.

Request URL: http://discourse.url.com/posts/1314

The URL is the key here. It is accessing post id 1314. Now look at the Method

Request Method: DELETE

It is using DELETE, instead of POST, GET, etc.

Combine the two and it will delete the post (so long as you also pass in the API_KEY and API_Username

4 Likes