3 ms·
`100` could be the employee id more than a name of the employee. So a query for id 100 returns the information associated with that id, nominally that it is cur
by afiori 4y ago
`100` could be the employee id more than a name of the employee. So a query for id 100 returns the information associated with that id, nominally that it is currently free and not associated with any employee.
Many online REST discussions focus too much on shallow linguistic analogies with verbs/nouns.
- dragonwriter 4y ago> So a query for id 100 returns the information associated with that id, nominally that it is currently free and not associated with any employee If you were doing a static website serving from a file system and said the same thing about a filename as a path component, you'd be seen as mad. But there is no difference when there is an id for a potential employee than a name for a potential file: if no employee/file exists when the server looks for the id/name, the correct result is 404 Not Found. The id isn't the resource, it's part of the path to the resource (and if it is the resource in that URL, you need a different scheme for when you need to find the employee pointed to by the id and not info about the id.)
- afiori 4y agoThat is defined by the previous segment of the path. The content of the file `/api/v1/employees/100` need to be defined off-band somehow since you cant actually put an employee on disk. moreover part of REST is that you are not responding with static files by path, but with representations of entities; the question then is whether the entity is the employee or the id. I agree that `/api/v1/employees/100` is not the best name for the id entity, something like `/api/v1/employee-id-status/100` might be more descriptive.