My services definitions list notes that to 'select votes' using VotingAPI I have to POST the parameters 'type' (mandatory), and to 'set votes' I have to post a 'votes' array (mandatory) and 'criteria' array (optional). What are the key pair results I need to call these APIs? For 'type' I have tried 'percent', 'points', 'node', 'vote, but none of those work. For the votes array I need entity ID but how/where can I find the entity ID? I am needing to set and select votes which have been submitted on nodes. Thank you
1 Answer
I solved it. The entity ID is the node id (nid) if you are voting on a node for example. eg for nid of 75, it is entity_id: 75. Other parameters are 'percent', 'points' or 'options' for vote type. And for tag it is 'vote' or whatever custom tag you created as a field. The 'value' of course is the number you are voting. If you are using standard settings for 5star, you enter eg 20 (for 1 star), 40, 60, 80 or 100 (5 stars). The mandatory parameters are entity_id, tag and value. I've read the system can work out the other details, eg user id from the currently logged in user.
eg this format worked for me: let newVote = ["votes":[["value":100,"uid":32,"entity_id":1,"entity_type":"node","tag":"vote","value_type":"percent"]]]
see Votingapi REST server call internal server error - 'services exception: missing entity ID'