Search code examples
restput

REST PUT + idempotency. How does the client provide a valid ID?


I know that PUT should be idempotent, and the client should define the ID for the object to create. But there is something I don't clearly understand: how does the client get an available ID? Should be there an other web service that provides one? Is there a best practice for this scenario?


Solution

  • client should first GET the Resource Representation

    then issue PUT with changes along with the id from above step

    It is also recommended to use If-Modified tags to avoid a conflict