|
|
|
|
|
by treis
1433 days ago
|
|
The difference is what you want to tell the client: >The 200 (OK) status code indicates that the request has succeeded. The payload sent in a 200 response depends on the request method. For the methods defined by this specification, the intended meaning of the payload can be summarized as: >GET a representation of the target resource; >The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists. If you to give the client the representation of the target resource (i.e. it doesn't exist) then send 200 and a body indicating it doesn't exist. If you want to tell the client you couldn't find a representation for the target resource then send 404 |
|
Let's say that you have a nested resource/path that will return devices owned by the employee so you will have this path:
`GET /api/v1/employees/1/devices/1` and this might return the first device owned by the employee.
Now what do you think the following request should return:
`GET /api/v1/employees/100/devices/1` where the employee with ID 100 does not exists but there is a device with the ID 1 owned by some other employee?
or
`GET /api/v1/employees/100/devices/1000` where both the employee with id 100 and device with id 1000 does not exists?
What do you think the response should be? Still 200?