1

I need to expose a poll to a mobile app. After doing some research I found out that I could receive the votes, through a web service, using the services_votingapi module, and the go-to poll to use was advpoll, or Advance Poll.

I've made a poll with several choices and added, in a services endpoint, the select_votes and set_votes services for votingapi. What I can't figure out now is how to send a vote using the service? there's some documentation at https://www.drupal.org/node/2145873 but I don't know the correct values to send. How do I know the correct entity ids, etc.?

0

Ok, I figured out how this is supposed to work. The required JSON document to POST to the set_votes service must be this:

{
  "votes":[
    {
    "entity_id":"1328",
    "tag":"f5a8bb465",
    "value":"1"
    }
  ]
}

entity_id is the nid of the Advance Poll, tag is the choice_id of the Poll Choice you want to cast the vote for, and value must always be 1, it's the vote.

In case you need to know those IDs, it may be a good idea to expose them through the node or the view services. Or use the Devel module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.