You can use this API request to add votes to an idea.
/services/v2/idea/[ideaId]/vote.json
The following parameters can be used in your add votes to an idea request:
Other options: wrap, v1
Permissions & Notes:
To post the votes using the "userId" you must have the ROLE_VOTE_OTHER_USER_IDEA permission under Custom Roles in the Advanced Editor.
- This is a role that may not be automatically created. You may create this role in the admin interface under Users & Groups > Manage > Custom Roles. The name should be ROLE_VOTE_OTHER_USER_IDEA, and you choose the label.
To set votes higher than 1 you must have the ROLE_SET_IDEA_VOTES permission under Custom Roles in the Advanced Editor.
- This is a role that may not be automatically created. You may create this role in the admin interface under Users & Groups > Manage > Custom Roles. The name should be ROLE_SET_IDEA_VOTES, and you choose the label.
All values are optional. If the votes are less than -1, or greater than 1, then it will just update the idea stats. Votes are set to 1 by default.
If userId is not set, the authorized API user will be used.
If date is not provided, the current time will be used.
This request was added in version 1.6.3.6.
Sample Request
A PUT add votes to an idea request to add votes (10) from a user (userId: 108) to an idea (ideaId: 838) sent to https://apidocs.cloud.answerhub.com using a basic authorization would look like this:
curl
-u "answerhub:test123"
-H "Accept: application/json"
-H "Content-type: application/json"
-X PUT
-d '{"userId":"108","votes":"10"}' "https://apidocs.cloud.answerhub.com/services/v2/idea/838/vote.json" -v
Expected Responses
Error Response:
If you have not created the custom roles mentioned in the note above, and/or have not granted those permissions, you will see an HTTP Status of 200 OK but the request will not be completed and you will get an HTML page as the response.
Successful Response:
- HTTP Status 200 - OK
{
"success": true,
"result": {
"score": 10
}
}
Community User Interface Result
- Returns JSON with a resulting score of the idea if the request is successful. In this example, userId 108 is the user called admin.
You will see idea 838 with 10 votes added, the username of the voter does not appear