REST - Shouldn't PUT = Create and POST = Update

post, put, rest

Solution

The difference is that a PUT is for a known resource, and therefor used for updating, as stated here in rfc2616.

The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource.

I do see where you are coming from based on the names themselves however.

I usually look at POST as it should be the URI that will handle the content of my request (in most cases the params as form values) and thus creating a new resource, and PUT as the URI which is the subject of my request (/users/1234), a resource which already exists.

I believe the nomenclature goes back a long ways, consider the early web. One might want to `POST` their message to a message board, and then `PUT` additional content into their message at a later date.

Problem

Shouldn't PUT be used to `Create` and POST used to `Update` since PUT is idempotent. That way multiple PUTs for the same Order will place only one Order?

Original source

Related problems