curl --request POST \
--url https://api.example.com/api/vote_post \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"post_id": 123,
"vote_type": "<string>"
}
'{
"message": "<string>"
}Upvote or downvote a post
curl --request POST \
--url https://api.example.com/api/vote_post \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"post_id": 123,
"vote_type": "<string>"
}
'{
"message": "<string>"
}POST /api/vote_post
"up" or "down"200 OK
{
"message": "vote counted"
}
400 Bad Request
{
"error": "missing post_id or vote_type"
}
post_id or vote_type is missing from the request body.
{
"error": "you can only upvote or downvote"
}
vote_type is not "up" or "down".
{
"error": "already voted this way"
}
401 Unauthorized
{
"error": "login to vote"
}
{
"error": "unauthorized"
}
403 Forbidden
{
"error": "cannot vote on your own post"
}
404 Not Found
{
"error": "post not found"
}
curl -X POST https://api.example.com/api/vote_post \
-H "Authorization: your-auth-token" \
-H "Content-Type: application/json" \
-d '{
"post_id": 123,
"vote_type": "up"
}'
{
"message": "vote counted"
}