Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From a RESTful point of view, what is the most appropriate HTTP method for the action of upvoting a forum post (like on StackExchange)?

I would say POST for voting and DELETE for canceling vote, but since users are only allowed to cast one vote per message, voting can be considered an idempotent operation so PUT can also be possible.

share|improve this question
up vote 3 down vote accepted

PUT /posts/323223/votes

A vote can be seen as an resource I would try that. I would not do any action agains the post (/posts/323223) since that is another resource. Then you would need to have an additional method and it starts getting complex.

share|improve this answer

I would argue you PUT your vote, or DELETE it. You don't actually edit the forum post, so POST would be inappropriate.

share|improve this answer

It mainly depends of what you consider to be your actual target object.

If your target object is the vote, then you should probably POST the vote to the system because you are actually changing the state of your target object (its internal vote counter).

Despite this, it is much more likely that you consider the forum post to be the target object of your operation and, in this case, most likely a PUT/DELETE operation set is more consistent with the REST phylosophy because you are not changing/editing your forum post. You are just putting/deleting a token into a counter. So, I would support the suggestion of Vain Fellowman.

The fact that voting should be an idempotent operation is another clue that should lead you in this direction. Think to this as a ADD/REMOVE operation over the "vote" member variable of your "forumPost" class/object.

Regarding how to tell if your real target object is the forum post or the vote, I think you should look at your code. The "object" (maybe a JSP page + a Java Controller + some Java Entity that refers to some DB table) that receives and handles this HTTP request is representing a forum post or a vote?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.