Discourse API Documentation


(Henning) #75

I think it has to be:

curl -X PUT -d usernames=username https://discourse.southlondonmakerspace.org/admin/groups/41/members.json?api_key=blahblahblhablahblah&api_username=system

Notice the passed data is usernames=xxxx - not users=xxxx.

(Tom Newsom) #76

Turns out that the issue was using the system user and the all users API key. I’ve created a new admin user with its own key and now it’s happy as Larry.

(Kane York) #77

Actually, the problem was that the & symbol was making your shell fork off a new process and run curl in the background.

You should be putting the api_key in the form data if possible.

(Tom Newsom) #78

Like this?

curl -X PUT -F api_key=blahblahbalh -F api_user=username -d usernames=username https://etc.etc.

Maybe the OP should be edited, if that’s the more appropriate syntax…

(oblio) #79

Are there any plans to have comment editing? I only see post creation :frowning:

(Dan Dascalescu) #80

If by that you mean updating/altering/modifying a post, then I’d love to see that as well.

My use case is doing a search and replace on posts after an import to fix formatting issues, and there are no good Ruby scripts to do this yet.

Also, the world is moving away from Ruby towards JavaScript, and a complete Discourse API would enable developers to use JS (or any other language) for batch modifications to posts.

(Dan Dascalescu) #81

Is there a way to limit/control the number of results returned by an endpoint? For example, I only want one latest topic. How could I specify that? I haven’t seen query parameters mentioned in the top post.

(Daniel M ) #82

You can do that with a PUT http request. I highly recommend reading this. It really helped when writing Java code for functions not implemented in the Java API.

(pjv) #83

Is there a way to use the API to get a full list of every user that has posted to a particular topic?

Or is there a way to do this through the front end somehow?

(cpradio) #84

Yep, query the topic.json
Discourse API Documentation

And read the details.participants array

(pjv) #85

Awesome! - thank you @cpradio

(pjv) #86

…Errrrr except that’s actually only giving me the summarized “Frequent Posters” that you can see beneath the topic’s first post

Is there any way to get an exhaustive list of every user who has posted to a given topic?

(Jeff Atwood) #87

That should be a complete list. What data do you see that makes you believe it is not?

(pjv) #88

On my site we are running a contest now where posting to a topic is the entry to the contest. We’ve got 150 individual replies/entries (and counting…) and when I run that query I get about 24 users - the same ones as seen below in “Frequent Posters” - but you can see that there are 158 (so far) actually in the topic:

EDIT: If it matters, I am on the stable channel, so running v 1.4.0

(cpradio) #89

Confirmed here using the URL I provided above, the json output has participant_count: 35 but the participant array in details is only 24…

Hmm, you might be able to use the Data Explorer Plugin (do you have that installed? – if so, and it works, I’ll work up a query for you)

(pjv) #90

I’ll install it but will have to wait on that until a quieter time to do the app rebuild. I don’t want to interrupt getting slammed by people entering our contest :scream_cat:

I’d really appreciate your offer of a query. I’d be able to hack it out eventually, but my SQL-fu is very sub-par (anyone ever need a Progress 4GL query though… do that in my sleep even after not touching a Progress DB in 6+ years).

(cpradio) #91

Not a problem, what info do you need about each user? Do you simply want their username, or username and email address (so you can quickly notify any winners)?

(pjv) #92

username and email would be fantastic - but even just the username would be totally adequate; I can then look up their profile in the site admin area.

(cpradio) #93

Here is the query to import into the Data Explorer Plugin
topic-participants.dcquery.json (440 Bytes)

(pjv) #94

Finally got a chance to install the plugin and import your query @cpradio.

Works perfectly.

Thank you so much for your help.