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.

2 Answers 2

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

0

I would still consider this scenario as PUT

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.