What's the idiomatic way to signal the caller about an error in API, in particular, "Not found" error?
Suppose, I have an url /api/vi1/check/123
.
What should I return in case
There is no such a record with id = 123? 404 error (Http status 404)?
status: 404 (http); data: { }
Or should I return OK status (Http status 200) and json with the internal status
status: 200 (http); data: { status: 404, msg: "Not found"}?
And (related to 1) what should I return if there is no such an url? Also Http 404 status?
Yes, I've seen the best practice videos and read the articles about REST APIs but this question wasn't answered clearly in those.