I would suggest that you use POST, not PUT, for the auto-increment key, or do not use the auto-increment key in the resource identifier.
If you use POST, then you would send POST to /users , not to /users/1 . The answer may redirect you to /users/1 or any other identifier.
If you use PUT, you can click the /users/10292829 , where the number is the unique resource key created on the client. This key can be time-generated or it can be a time hash, session identifier, and some other factors to guarantee unique value for your client audience. Then the server can generate its own automatically incremented index, other than 10292829 or whatever.
For more on this, see PUT vs POST in REST
Continuation of.,.
If you enable PUT to / users / XXXXXXX for all users, you will receive two unique unique keys that belong to the same resource. (10292829 and 1 can refer to the same user). You will need to decide how to allow each of these different keys to be used in a REST URL. Due to the need to coordinate the use of these two different identifiers, I would prefer to use the first option, POSTING to /users and get the unique unique REST URL of the created resource in the response.
I simply re-read the relevant section of RFC 2616 and saw a return code specially designed for this in REST applications:
10.2.2 201 Created
The request has been completed and a new resource has been created. A newly created resource can be referenced by the URI (s) returned in the response entity, with the most specific URI for the resource specified by the Location header field. The answer SHOULD include an object containing a list of characteristics and locations of resources from which the user or user can select the most suitable one. The entity format is determined by the media type specified in the Content-Type header field. The source server MUST create a resource before returning the 201 status code. If the action cannot be performed immediately, the server MUST respond to a 202 (Accepted) response instead.
So, the RESTful path to go to is POST to /users and return 201 Created , with the Location: header indicating /users/1 .
Cheeso
source share