Understand the difference between PUT and POST.
PUT is intended to replace the resource ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6 ) that the URI points to with a new one. And this is idempotent, i.e. How many times you call it with the same payload, the result is the same; it will make the same resource available through the URI.
So, if there is no resource, a new one is already being created. Even in this case, the result will be the same, that is, it will make the same resource available through the URI.
POST means creating a sub-resource ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5 ) to the resource pointed to by the URI. If the resource is a list, it will add an element to it. If this is an element, then it should add something to the element, maybe an attribute.
So, ideally, if the element that the URI points to is not available, then this should be an error condition. Maybe 404. POST is an addition to an existing resource.
Coming to your question, it is better to use POST with "/ entity /" as a URI as described above. You must not use a non-existent resource UUID in a URI with a POST method. If you use PUT, use "/ entities /".
POST /entities/ HTTP/1.1 Content-Type: application/json { UUID: <UUID>.. OtherStuff: ... } PUT /entities/<UUID> HTTP/1.1 Content-Type: application/json { UUID: <UUID>.. OtherStuff: ... }
The answer should be the same
HTTP/1.1 201 Created Location: http://www.examples.com/entities/<uuid>/
although PUT is idempotent, but if the PUT method is used again, then it should use a 200 or 204 response.
Second question: ideally, complete resource information should be in the PUT payload, and not just in the URI.