Skip to content
nvasilev edited this page Nov 13, 2014 · 1 revision

Vote

Retrieve Vote

Request:

GET http://127.0.0.1:8080/polls/1/alternatives/1/votes/1
Accept:application/hal+json

Curl:

curl -i -H "Accept:application/hal+json" -X GET http://127.0.0.1:8080/polls/1/alternatives/1/votes/1

Response:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/hal+json
Transfer-Encoding: chunked

{
  "id" : 1,
  "email" : "a@b.com",
  "_links" : {
    "self" : {
      "href" : "http://127.0.0.1:8080/polls/1/alternatives/1/votes/1"
    },
    "votesCount" : {
      "href" : "http://127.0.0.1:8080/polls/1/alternatives/1/votes/count"
    },
    "alternative" : {
      "href" : "http://127.0.0.1:8080/polls/1/alternatives/1"
    }
  }
}

Create Vote

Request

POST http://127.0.0.1:8080/polls/1/alternatives/1/votes/1
Content-Type:application/json
Accept:application/hal+json

Request's payload:

{
  "email" : "a@b.com"
}

Curl:

curl -i -H "Content-Type:application/json" -H "Accept:application/hal+json" -X POST http://127.0.0.1:8080/polls/1/alternatives/1/votes -d '{ "email": "a@b.com" }'

Response: 201 CREATED

{
  "id" : 1,
  "email" : "a@b.com",
  "_links" : {
    "self" : {
      "href" : "http://127.0.0.1:8080/polls/1/alternatives/1/votes/1"
    },
    "votesCount" : {
      "href" : "http://127.0.0.1:8080/polls/1/alternatives/1/votes/count"
    },
    "alternative" : {
      "href" : "http://127.0.0.1:8080/polls/1/alternatives/1"
    }
  }
}

Votes Count

Request:

GET http://127.0.0.1:8080/polls/1/alternatives/1/votes/count
Accept:application/json

Curl

curl -i -H "Accept:application/json" -X GET http://127.0.0.1:8080/polls/1/alternatives/1/votes/count

Response: 200 OK

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/hal+json
Transfer-Encoding: chunked

3
Clone this wiki locally