Sets reply_to when creating a message through the API?

Hi. Is there a way to specify the message ID to which a new message responds when we create this last one through Discourse API?

I believe you should be able to use the key - reply_to_post_number in your POST request

http://docs.discourse.org/#tag/Posts%2Fpaths%2F~1posts%2Fpost

3 Likes

Hello, I allow myself to reopen this thread. I’m using the API right now to convert some custom conversation system to discourse, and I’m struggling with the replies.

I use the /posts API, with the reply_to_post_number parameter and the post does not show as a reply at all. I’ve checked that the reply_to_post_number matches the post_number of the post above, to no avail.

I’ve tried reverse engineering the API, tried adding nested_post to the request as this was the main difference between my call and the one in the interface, but the result is still the same…

Note that the post created through the API does have the reply_to_post_number correctly set. It just doesn’t show up as such on the interface…

Thanks for any lead !

1 Like

OK, i just created an account because i had the same problem and found the solution!

Like Bertrand said; you can set the reply_to_post_number all day long but in the UI it is not shown as a regular reply. When i tried to create a reply however in the same way but with my admin account it DID work! This indicated it had something to do with permissions.

I found out that if i changed the Security settings of the Category the post belonged to, so that the default Everyone group had all rights (so also Create rights which was unchecked by default for me) it now WORKS! Not sure why this right is needed as Create already works (i can create a post), and the Reply right was already checked but anyway… it WORKS :smiley:

1 Like

Hi @greedNotGood @Bertrand_Gorge I’m building a project where I need to add a reply to a post via discourse api. I’m new to discourse, Can you help me with a curl request or some documentation for the same? Appreciate your help.

Gaurav T

Hello @Gaurav_Tewari the documentation is here: Discourse API Docs

You have curl samples at the top of this same page. Good luck !

Hi all.

I’m trying to get a post created to show as a reply to another post, but as multiple people above, I’m not very successful.

I’m sending reply_to_post_number as one of the keys in the payload to /posts.json, with value taken from another posts post_number, but that is not doing anything. The category security settings are fully permissive to all users.

Interestingly the response changes when I use reply_to_post_number in the post request vs when I don’t. If I don’t send it with the request, 'reply_to_post_number': None, will be present in the response, however, if I do send it with the request with an integer value pointing to previous post, the response doesn’t have that key whatsoever.

This seems totally undocumented, which I very much realize, but any help would be appreciated. Discourse API docs are of no help as it is not mentioned there at all.

thanks

1 Like

I tried to reply to a post with the API and it works:


However, there is indeed missing info in docs.discourse.org. :slight_smile:

If you’re willing to, you can also contribute to this documentation: Contribute to the Discourse API Docs

2 Likes

The strange thing is that I can do it from insomnia as well, or any any plain request, but when doing it from python (just using requests, not the python api), it doesn’t seem to work.

I just noticed that the data seems to be there but it’s not showing in the main view.

Even in safe mode (well, just to be sure…)?

What does https://your-discourse.com/posts/{id}.json (where {id} is the new post id) return?

Is there a "reply_to_post_number" key value?

I don’t think I can help further on this unfortunately and I never used Python, I’ll let real connaisseurs try to help you :slight_smile:

Maybe pasting your script would give some clue?

It’s hard to tell from your example if this is the case, but if you reply to a post and your reply is the next post, we hide the reply to post info in the UI.

4 Likes

Batman Facepalm GIF by WE tv

If there was a bigger facepalm, it would fit here. That is of course the issue and I just ended up testing on precisely the type of post that is next to it’s reply target. It makes perfect sense of course, just not obvious why it sometimes shows and sometimes it doesn’t.

Nevertheless the mystery is solved, thank you folks. Much appreciated.

3 Likes

If that can help you feel better, I think many people working at Discourse don’t know all features of the software :grin: (at least, this makes me feel better :laughing:)

2 Likes

Oh I totally get that. I run a company maintaining and supporting a large open-source project. There comes a point where collective knowledge is the only way.

4 Likes