vendredi 21 septembre 2018

HTTP Status Code when the Parent Resource is not longer live

In our Organization, the items in our inventory are called stocks. Each stock has a sortScore associated with it. An internal API is exposed to another team in the organization to update the sortScore of the stock.

PUT /api/stock/{stockid}/sortscore

This request updates the sortScore of the stock. It may happen that the stock is no more live(it is sold), but for some reason, the internal API for updating the sortScore is still hit by another team.

According to me, here the resource is sortScore and the parent resource is the stock, which isn't live anymore(It used to be live at some point of time). Even though the stock is no more live, we still keep a record of it somewhere in our Database.

Some of us are having arguement about the HTTP Status code we are sending when the stock is not live anymore. Since the resource is not available at the intended Resource Identifier(URL), we are sending NOT FOUND. But some of our colleagues are saying that since the stock used to be live at some point of time, the Status Code should be of 2xx series with the message that This stock is not live anymore.

Now I am here to know what the people from stackoverflow thinks about what the correct answer should be?




Aucun commentaire:

Enregistrer un commentaire