In REST terminology, which is how interfaces where POST
is used to create an object (and PUT
to modify, DELETE
to delete and GET
to retrieve) are called, the POST
operation is attributed un-'safe' and non-'idempotent, because the second operation of every other type of petition has no effect in the collection of objects.
I doubt there is an "official" way to deal with this, but there are probably some design patterns to deal with it. For example, these two alternatives may solve this problem in certain scenarios:
- Objects have unicity constraints. For example, a record that stores a unique username cannot be duplicated, since the database will reject it.
- Issue an one-time use token to each client before it makes the
POST
request, usually when the client loads the page with the input form. The first POST
creates an object and marks the token as used. The second POST
will see that the token is already used and you can answer with a "Yes, yes, ok, ok!" error or success message.
Useful link where you can read more about REST.