0
votes

I have a REST request (Not completely REST though). The input data is received via HTTP payload as XML and thus the record to be read is specified in the xml as,

<Item> <ID>1</ID> </Item>

Here, if the ID '1' is not found in database, should I return 404 Not found.

According to https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html, 404 Not Found is referred as The server has not found anything matching the Request-URI. But in my case, the URI can be reached successfully and the data in payload could not be found. Is it appropriate to use 404 or should I use any other status code?

1

1 Answers

2
votes

First of all, why are you sending a payload to retrieve data? If you want to retrieve data in a RESTful way, you should send the id in the path, like /some-resource/1. I hope there is a very good reason to don't follow that standard.

In any case, returning a 404 is the best approach, in my opinion. Any client would expect a 404 if the resource was not found, even when the formal definition specifies that the resource is in the URL.