1

I'm building a REST API and any time you change an object, the backend updates the "last modified date" to now. I have no control over this backend code so it has to stay this way. Another thing it changes is the "last modified by" which stores a username.

In my eyes, this changed "last modified date" and "last modified by" makes updating anything non-idempotent. Does that mean that updates should occur with POST instead of PUT?

My concern is that these days people assume that PUT is for updating, and my API will violate the principle of least surprises.

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

2 Answers2

1

I would consider this to still be a PUT

In my eyes, the update should not even care what the last modified date was and it should just be set no matter what on update. If the new document you're sending to the server is not different from the one that is currently on the server, there shouldn't be any change made to the modified_time.

If you wanted to have a scenario where modified_time is change (ie. maybe you're refreshing a TTL) then I would suggest that your refresh request is a POST.

Maybe these other posts on this issue could help you:

PUT vs POST in REST

Put and idempotent

Community
  • 1
  • 1
jmadewell
  • 170
  • 1
  • 5
0

I would still consider this scenario as PUT