News for hackers. Stuff that matters.
Re:I've been abusing HTTP Status Codes in my APIs for years by afiori on Wednesday July 13, 2022 @04:47PM (#32088549)
`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.

Re:I've been abusing HTTP Status Codes in my APIs for years by dragonwriter on Wednesday July 13, 2022 @08:28PM (#32090466)
> 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.)

Re:I've been abusing HTTP Status Codes in my APIs for years by afiori on Thursday July 14, 2022 @06:54AM (#32094310)
That 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.