Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

Poll Rest

No security coverage
View on drupal.org

Overview

The Poll Rest module provides a REST endpoint to retrieve and submit choices or votes based on the Poll module.

Requirements

Post-Installation

  1. Enable poll, rest, and poll_rest modules.
  2. Head over to /admin/config/services/rest and enable the poll vote resource.
  3. 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
}

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Oct 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 3
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.0.0-alpha4 Pre-release Oct 8, 2024
1.0.0-alpha3 Pre-release Oct 3, 2024
1.0.0-alpha2 Pre-release Oct 1, 2024