API endpoint for voting

(Raphaël Droz) #1

That would open the vote feature to mobile user, external app’, …

The API seems to lack a “votes” definition
The Poll::vote and add_anonymous_votes function is already there, but lack a controller but since votes are a plugin, the issue may have to be that plugins get the ability open API endpoints

(Rafael dos Santos Silva) #2

Everything in Discourse has API support:


curl 'https://meta.discourse.org/voting/vote' -X POST --data 'topic_id=51247'


curl 'https://meta.discourse.org/voting/unvote' -X POST --data 'topic_id=51247'

(Raphaël Droz) #3

how, thanks! (I couldn’t find it inside http://docs.discourse.org/ [which does not work with FF btw])
How does is apply/not apply to anonymous users?
Will that call require user’s token if anonymous voting is not allowed?

(Rafael dos Santos Silva) #4

Vote is a plugin, docs are only for core.

OMG, just saw this now. You created a post on the #plugin:voting category and are asking questions linking the poll plugin code. My last reply was about the #plugin:voting plugin, please elucidate me.

(Blake Erickson) #5

I’m able to load http://docs.discourse.org in firefox 54.0 on Windows just fine and I know it worked on earlier versions too. Is it really not working for you in firefox?

(Blake Erickson) #6

The controller is inside of plugin.rb here:

And the routes for it are here:

If anonymous voting is not allowed it should require a users token.

I’m thinking about adding the api endpoints for plugins as well to the api docs. I can just create a tag in the docs for each plugin that is added.

I’ll work on adding the poll endpoints to the docs. In the meantime though you can just open up the chrome inspector and go the networks xhr tab and view the requests as you make them.