LoudVoice API \ Votes \ Cast vote

Resource/URI - Discussions GET POST PUT DELETE
Discussions /loudvoice/discussions.json List all discussions Create a discussion
Discussion /loudvoice/discussions/<discussion_token>.json Read a discussion Update a discussion Delete a discussion
Discussion messages /loudvoice/comments/<discussion_token>/comments.json Read discussion comments
Resource/URI - Authors GET POST PUT DELETE
Authors /loudvoice/authors.json List all authors Create an author
Author /loudvoice/authors/<author_token>.json Read an author Update an author Delete an author
Resource/URI - Author Sessions GET POST PUT DELETE
Author Sessions /loudvoice/authors/sessions.json List all sessions Create or update a session
Author Session /loudvoice/authors/sessions/<session_token>.json Delete a session
Resource/URI - Comments GET POST PUT DELETE
Comments /loudvoice/comments.json List all comments Create a comment
Comment /loudvoice/comments/<comment_token>.json Read a comment Update a comment Delete a comment
Resource/URI - Votes GET POST PUT DELETE
Votes /loudvoice/votes.json List all
votes
Vote /loudvoice/votes/comments/<comment_token>/authors/<author_token>.json Read a vote Cast a vote Delete a vote

Workflow

Request: the code to send to the API

Send an API request to this endpoint in order to cast a vote for a comment:

PUT /loudvoice/votes/comments/<comment_token>/authors/<author_token>.json

The <comment_token> and <author_token> must be replaced by the unique identifiers of the comment that is being voted for and the author leaving the vote.

Authors may not vote for their own comments and may not cast more than one vote per comment. If there is already a vote by that author for that comment, that vote will be removed before adding the new entry.

PUT data to be included in the request

{
  "request": {
    "do_update_counters": "#do_update_counters#",
    "vote": {
      "direction": "#direction#",
      "ip_address": "#ip_address#"
    }
  }
}
Key Description
Flag
do_update_counters
boolean
If disabled, adding a vote will not update the internal vote counters of the comment. You can manually set the counters by updating the comment itself.
Default: true
Vote Metadata
* direction
string, predefined
The direction of this vote. May either be up or down.
Example: up
ip_address
string, IPv4
IP address that was used to leave the vote.
Example: 172.16.0.1

Result: the code returned by the API

On success, the API either returns the HTTP status code 201 if a new vote was added, or the HTTP status code 200 if an existing vote was replaced. A different HTTP status code indicates that an error occured while processing the request.

Example Resultset

{
  "response": {
    "request": {
      "date": "Mon, 21 Oct 2019 16:03:40 +0200",
      "resource": "/loudvoice/votes/comments/345a5258-ab80-4f31-aefb-03e2eddf25b8/authors/3f76faa4-4188-463a-8f4f-555286039014.json",
      "status": {
        "flag": "created",
        "code": 201,
        "info": "Your request has been processed successfully and resulted in a new resource being created"
      }
    },
    "result": {
      "data": {
        "vote": {
          "comment_token": "345a5258-ab80-4f31-aefb-03e2eddf25b8",
          "author_token": "3f76faa4-4188-463a-8f4f-555286039014",
          "direction": "down",
          "ip_address": "323.456.879.111",
          "date_creation": "Mon, 21 Oct 2019 16:03:40 +0200"
        }
      }
    }
  }
}

User Contributed Notes