News for hackers. Stuff that matters.
Re:I've been abusing HTTP Status Codes in my APIs for years by dragonwriter on Wednesday July 13, 2022 @01:18PM (#32085755)
> A GET request to that path should return the current state of the resource at the path

There is no resource at the path.

> As you note, the current state of that entity is that it does not exist.

A thing which does not exist does not have state. Existence (and even moreso non-existence) isn’t a state, existence is logically presupposed in any description of state.

Re:I've been abusing HTTP Status Codes in my APIs for years by treis on Wednesday July 13, 2022 @01:25PM (#32085866)
>existence is logically presupposed in any description of state

Then please explain how you can write and I can understand the phrase "A thing which does not exist".

Re:I've been abusing HTTP Status Codes in my APIs for years by dragonwriter on Wednesday July 13, 2022 @01:44PM (#32086172)
Its convenient linguistic shorthand for a common case which would be more properly be described as “a concept of a thing which does not correspond to any actual thing”. While the equivalent linguistic shorthand has been present in most languages for quite a long time, the recognition that the confusion it can sometimes produce between concepts and concrete things is a category error is, while not nearly as old, also fairly old; it is central to Kant’s argument against the ontological argument for God’s existence, for instance.
Re:I've been abusing HTTP Status Codes in my APIs for years by treis on Wednesday July 13, 2022 @03:28PM (#32087664)
And why shouldn't we go with the convenient linguistic shorthand instead of the esoteric ontological argument?
Re:I've been abusing HTTP Status Codes in my APIs for years by dragonwriter on Wednesday July 13, 2022 @05:33PM (#32089018)
> And why shouldn't we go with the convenient linguistic shorthand

Who said you shouldn't? The shorthand is convenient. But it doesn't mean what other statements with the same shape mean. A thing which isn't doesn't have a state or representation.

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.