HTTP status code for a logical resource

I faced a dilemma when developing an API at work. Say I have a route for a resource as follows:

/ order /: OrderId / returnable

This resource should check if the order can be returned to the store or not. Now it is responding to status code 200 if it is IS returned and 404 if not.

A colleague rightly pointed out that the resource did not go away and that I should use 200 for any answer, and then respond with a body containing my results.

Both have semantic meaning, and I do not see a clear winner.

What response status code should we use? And should there be something in the body?

+4
source share
1

. (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) , 404 - " , -URI". -, . , API, HTTP 200. , , -, , .

"orderId" , HTTP 404.

+4

Source: https://habr.com/ru/post/1539449/


All Articles