I am currently designing a JSON RESTful API which should have a boolean endpoint such as /item/vote which can either be false meaning that a user has not voted for a specific item or true meaning that he has voted.
I am currently struggling to select one out of multiple possible designs:
HTTP status codes
PUT /item/vote => set to true DELETE /item/vote => set to false GET /item/vote => status code 204 => true | status code 404 => false
JSON
PUT /item/vote HTTP/1.1
Content-Type: application/json
{
"vote": true
}
GET /item/vote HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json
{
"vote": true
}
Is any of these two approaches better or is it just a matter of preference? I am currently preferring the HTTP status code approach because I have already seen it.
voteStatus) and not like a verbvote.votecan be a noun.