I have an API which allows a user to update their system status; and a separate call to retrieve system status updates from other users. Would it make sense to unify them under a PUT request where a user would request a PUT update with their own status update, and they would receive the status updates of other users?
My solution would allow the PUT request to call the GET request method internally. The reason behind this is that when a user updates their system status they should be informed of other users status immediately, and I don't feel that having 2 seperate requests is necessary – and should be optional.
I intend to keep the GET request for other users status as a status update for a user is not necessarily required in order to retrieve other users status', but once they update their own status is it vital that they get information about other users.
Best Answer
I don't think you should, for a few reasons:
PUT
request it exactly that. They are sending you information and you should take it. You shouldn't change the semantics to "I'll take your data, if there's a mistake, I'll give you an error, but I'll also give you other data that you may or may not actually want or need.PUT
request wants the related data?PUT
request? Is this consistent with your other APIs?GET
andPUT
at the same time?).If you absolutely want this, you should make it an optional flag or call. If they specifically say
fetchMeTheRelatedData
then give it to then, but do not give it to them by default.