Page Vote Ajax API
POST
/page/{ id }/vote.json
An API allowing you to implement page voting (up or down) for your website's users.
This API affects the upvotes
and
downvotes
properties of
the Page object.
A user is only permitted to vote once per page, but is also permitted void/undo their vote. Before interacting with this
API, within your EVML template, you may wish to determine whether a user has already voted using the
userHasVoted()
,
userHasVotedDown()
,
and/or
userHasVotedUp()
methods of the Page object.
Parameters
dir
The direction of vote may be one of the following values:
|
Response
A successful vote request will return a JSON response with the following properties:
success
A boolean value, |
upvotes
The total number of upvotes for the page after the vote has been cast. |
downvotes
The total number of downvotes for the page after the vote has been case. |
Example response
{
"success": true,
"upvotes": 1,
"downvotes": 0
}
Errors
You may encounter the following error status codes when calling this API:
400
A Bad Request response may be encountered when:
|
403
A Forbidden response may be encountered when the user is not recognised. |
404
A Not Found response may be encountered when the the page |
405
A Method Not Allowed response may be encountered if the vote was not submitted via |
422
An Unprocessable Entity response may be encountered if the vote data code not be saved. |