httppostputidempotent

use case of POST as a non idempotent http request method


Why would one use POST at all if PUT can be used to create and update records and is idempotent. in what case would you not want the idempotency?


Solution

  • With PUT the client is deciding the URI of the resource that's being created.

    In many cases developers want the server to decide the URI (for example, if the URI contains some incrementing unique database id).

    So generally it's a good idea to use PUT to create new resources, unless the server wants full control over the namespace. In practice this is most cases.