I have the resource OrderRequest which I guess can be qualified as process. The OrderRequest can be create of update. The create should be idempotent, because creating the same order request 2 times is undesired. At the same time the POST
is not idempotent and it does not always return the same result. I use a combination of Client side generated Id and server side generated Id. When create is executed the client side generated Id is used so it ends up as
PUT /orders/clientGeneratedID
It will return also a server generated Id that can be used. There is a subtle difference between the two Ids because having clientGeneratedtID
means also that there is a "dealer order" associated with the order.
Once created a modification is modified via clientGeneratedID
or server generated Id.
POST /orders/{clientGeneratedID
or serverGeneratedID
}/modifications
Reading through various posts I understand there is some confusion about POST
and PUT
with regards of what is create and what is UPDATE
.
My understanding is that since I supply the Id and the URL the correct verb for my create is PUT
. At the same time since I am creating a process it does not sound correct for me that PUT
should be also update I am not entirely replacing the resource which is a prerequisite for using PUT
for update. So I have decided to use POST
.
Is it wrong that I have both PUT
and POST
in such way? Am I doing it right? I understand that I can do an idempotent POST
for create. But is there a general guideline that you should use either PUT
or POST
but don't combine and what about the fact that I use them in reverse PUT
for create and POST
for update?