Hi,how to use this resources?I have tried this way : http://url/endpoint/votingapi/select_votes.Is it wrong url?Thanks

Comments

tyler.frankenstein’s picture

Status: Active » Closed (works as designed)

With the latest development snapshot...

To set votes, do a POST to rest/votingapi/set_votes.json, and send along this JSON, for example:

{
  "votes": [
    {
      entity_id: 2,
      value_type: "points",
      tag: "vote",
      value: 11
    }
  ]
}

To get results, do a POST to rest/votingapi/select_votes.json, and send along this JSON, for example:

{
  "type":"results",
  "criteria":{
    "entity_id":"236",
    "entity_type":"node",
    "tag":"vote"
  }
} 
rahulchaurasia3592’s picture

I've the same issue and unable to figure out the solution by the above code. Please have a look at my use case -

I've installed Advance Poll module, services voting api on my drupal site. I've created polls on the website using (Add Content-->Advance Poll) and it is showing fine on the website.

My Problem - I want to show those polls(Questions with 4 choices or options) on the android mobile and also want the user to give his vote so that I can send the selected choice back to the server. Once the voting has done, I'll be showing him the voting result. I want to do this using the rest api.

What I've done so far

I've installed rest server module along with the services view module. I've created a view of content-type "Advance Poll" and I've added the Question field and Choice Field. Using this way, I am getting the questions and choices in JSON format using the services views module. So, the polls are showing on the mobile side. I need a way to send the selected choice back to the server.

Any help would be appreciated.

gumdal’s picture

Thank you for this quick documentation! How do I get all votes specific to a user? This is required to show in the UI whether the user has already voted the article or not.