This project is not covered by Drupal’s security advisory policy.
Overview
The Poll Rest module provides a REST endpoint to retrieve and submit choices or votes based on the Poll module.
Requirements
Post-Installation
- Enable poll, rest, and poll_rest modules.
- Head over to /admin/config/services/rest and enable the poll vote resource.
- Enable the GET, POST, DELETE method.
Usage
GET
The implementation of GET verbose can response options or votes from a poll.
Request options
curl -v http://locahost/api/v1/poll/1?query=choices
Response options
- `chid`: is the choice id.
- `name`: is the name of the option.
- `action`: is the uri to request a vote of a choice
{
"raw_question":"What development methodology do you use??",
"pid":"1",
"user_vote":null,
"choices":[
{
"chid":4,
"name":"KanBan",
},
{
"chid":5,
"name":"RUP",
}]
}
Requests votes
curl -v http://locahost/api/v1/poll/1?query=votes
Response votes
{
"raw_question":"What development methodology do you use??",
"total_votes":"1",
"pid":"1",
"user_vote":null,
"results":[
{
"choice":"RUP",
"display_value":"100% (1 vote)",
"value":"1",
"percentage":100,
"is_current_selection":false
},
{
"choice":"KanBan",
"display_value":"0% (0 votes)",
"value":0,
"percentage":0,
"is_current_selection":false
}]
}
POST
The implementation of POST verbose is use to vote a choice.
Implements some validation, for example, if user is Allowed to Vote.
Request
curl -d '{"chid":"1"}' -H "Content-Type: application/json" -X POST http://locahost/api/v1/poll/1/vote
Response
{
"error": false
}
DELETE
The implementation of DELETE verbose is use to cancel a vote of a User.
Implements some validation, for example, if user is Allowed to cancel his vote.
Request
curl -X DELETE http://locahost/api/v1/poll/1
Response
{
"error": false
}
Project information
- Project categories: Decoupled, Integrations
3 sites report using this module
- Created by lukio on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
Releases
Development version: 1.0.x-dev updated 8 Oct 2024 at 14:07 UTC
