It really depends on how your resources are represented.
One way to keep PUT still idempotent in that case would be to treat updated_at as a server generated value which the client has no control over, which is actually true in most cases. The from a client's perspective, the resource representation they send to the server is same every time and server can respond in an idempotent manner.
Nice article, I didn't focus on PATCH and idempotency so far.
Reading through the article a question arose: say we have an entity with an 'updated_at' attribute where we store the timestamp of the last update.
Since the 'updated_at' is changed every time we save the entity, saving through a PUT method would break the idempotency, is it correct?
In this case, should we consider to use a PATCH to update that kind of entities?
Thank you!
It really depends on how your resources are represented.
One way to keep PUT still idempotent in that case would be to treat
updated_at
as a server generated value which the client has no control over, which is actually true in most cases. The from a client's perspective, the resource representation they send to the server is same every time and server can respond in an idempotent manner.Ok, that means that a GET shouldn't return the 'updated_at' attribute?
Sorry if I bother :)
Why should it not?
Resource for
PUT
andGET
can look different.Just asking :)
Thank you for your clarification, it was very useful