Understand the difference between PUT and POST.
PUT is meant to replace resource (http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6) pointed to by the URI with a new one. And it is idempotent i.e. how many times you invoke it with same payload, the result is same; it will make the same resource available through the URI.
So, if the resource is not there already a new one is created. Even in this case the result is same i.e. it will make the same resource available through the URI.
POST is meant create 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 then it will add an item to it. If it is item then it should add something to the item, an attribute may be.
So, ideally if the item pointed to by the URI is not available then it should be an error condition. May be a “404”. POST is all about adding to an existing resource.
Coming to your question, it is best to use POST with “/entities/“ as URI as per the description above. You should not use a non-existent resource UUID in the URI with POST method. If you are using PUT then 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: ...
}
Response should be 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 200 or 204 in response.
Your second question: ideally the full resource detail should be in the PUT payload instead of just URI.