Comments (7)
Really depends on how REST-ful you want to be, right? If I remember correctly, in "proper" REST-style, the existance of an URL like /data/123 implies the existance of the corresponding UPDATE and DELETE calls, and as such, they should return 404.
from ods.
If a request like "GET /data/123" points to a non-existing ID, I would probably just return a 404. Or, as described in https://stackoverflow.com/questions/20922543/correct-http-status-code-for-existent-resource-but-non-existent-entity, you could return 422. Just returning 400 would only make sense to me if you send a completely invalid identifier (like "hello" instead of a number). So, I would assume that a failing DELETE or UPDATE should behave the same, right?
The question is of course - shold we return 400 or 404 if an endpoint does not exist? I honestly don't know.
One of the reasons why I personally don't like using the http verbs and status codes :D
{
success: true,
data: {
// ...
}
}
{
success: false,
error:
/*
Mabye, an entry from an enum. Or some additional data.
Semantically, it is completely clear what the error means. Which is the ultimate goal of error handling for an API.
*/
}
This makes it super easy to create types in TS. And you don't need to think about status codes and the like. But it is probably the opposite of a proper REST API :D
from ods.
I like the idea of the 422 code. Anyone disagreeing?
from ods.
I think HTTP code 422 is a more appropriate response if the data is understood by the server but is still not valid (invalid format).
And in the case of an unavailable URL (with or without query params), I would say 404.
https://datatracker.ietf.org/doc/html/rfc4918#section-11.2
from ods.
Okay, I also had another read and I guess common sense is to use 404 in those cases (entity does not exist). If I remember correctly, this should be the case in most places of the APIs.
from ods.
Agreed, my stance was always to use 404 there.
from ods.
GitHub also uses 422 for non-existing IDs (or similar). See for example https://api.github.com/repos/jvalue/ods/commits/this-does-not-exist But I guess there is no "this is absolutely the correct status code" for this case, so 404 is probably fine as well.
from ods.
Related Issues (20)
- Upgrade TypeScript Service Setups HOT 1
- Incompatibility between UI and Pipeline-Serivce HOT 2
- Adjust paths after repository rename HOT 2
- CDC Test and Pact Readme HOT 3
- [BUG] Failed to create new Datasource HOT 2
- UI image crashes HOT 4
- AMQP mismatch between implementation and documentation for Adapter-Pipeline topic
- VM2 Security Alert
- UI StorageView broken HOT 3
- Bug in UI - Collected data is not shown HOT 1
- CI Image Publishing
- Storage: use JSON schema to structure data and spawn GraphQL interface HOT 1
- UI update datasource bug
- Datasource creation back button issues HOT 1
- Adapter NodeJs refactoring preparation HOT 1
- Storage MQ query timeout HOT 3
- Cannot delete some Datasources HOT 1
- UI bug: UI not rendering in Firefox
- AdapterJS: Remove Knex and make linter work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ods.