Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

PUT verb being used in a non-idempotent way #38

fernandoacorreia opened this Issue Sep 2, 2011 · 0 comments


None yet
1 participant

fernandoacorreia commented Sep 2, 2011

As stated in the HTTP 1.1 specification:

"Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. "


As implemented, repeated PUT request to e.g. "/project/{projectId}/task" will not be idempotent; each request to the same URL will create a new task.

That would be the semantics expected of POST, not of PUT. In short, PUT replaces the content of a URL, POST adds content subordinate to a URL.

"The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request."


"The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line."

This semantic inconsistency would be more obvious if the URL emphasized that the resources are COLLECTIONS, not individual objects. For instance:


is a list of tasks, not a single task, and "/projects" is a list of projects, not a single project.

The suggested resolution is to replace PUT with POST when the expected action is to create a new resource subordinate to a URL and, optionally, pluralize the resource names to make that clearer.

See also:






Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment