I have an API where a put request may not result in changes to the underlying data. If this occurs, I am sending back a 200 and the ETag remains the same as it was if nothing happened. The client, though, may not realize nothing was changed since they won’t necessarily be tracking the ETag values. And a 200 value means the operation completed successfully, although it really didn’t since the intent was to PUT but no data was really PUT.
So, I wonder whether there is a better way of handling this to alert the client that there was “nothing to do” because their request did not actually modify data. I am thinking of sending an additional X-Request header, but that seems inelegant. Are there any status codes I am missing that might be appropriate for this use case?
Consider
204 No Content– it’s an OK code, and you can interprete the lack of body as a mere acknowledgement.