Comments (2)
I wouldn't recommend using 404 to indicate an empty shopping cart. If there is an explicit process to create a cart and delete a cart then a 404 would indicate the need to create a cart. A client that requests to see the contents of the cart when the cart is empty, is not a "client error". At least that is quite a stretch.
Assuming that carts are implicitly created when you add items to them, there are two options for indicating an empty cart. You can return a 200 and a empty object/array, or return a 204 that has no response body at all.
from api-guidelines.
See here: https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#51-errors
4xx indicates that client has sent an invalid request (wrong path, bad format, unsupported method, etc.). And if I get you description right, then empty card is not a problem, it is a valid state of application => 404 does not suet here.
200 vs 204 is like empty array vs null. Decision here depends on you style and preferences.
Personally, I prefer to have 200 and be sure that I always receive array (empty or not) in a response body.
from api-guidelines.
Related Issues (20)
- State machine pattern HOT 1
- Throttling pattern
- Graph specific HTTP Request/Response
- Shared Type Design Pattern
- HTTP Return Codes don't mention HTTP HEAD HOT 8
- Vanity url is broken with leading slash HOT 2
- Guidance on response payload with 201
- arbitrary JSON pattern/anti-pattern
- Add guidance for pageable post operations
- Fix content table in the main Graph guidelines. merger enum and evolvable enum patterns
- querying arbitrary number of keys in a dictionary insted HOT 1
- Add clarity to expand requirement
- The 'at' naming convention
- Xbox box 360 live
- Vague guidelines about point query support
- Error message localization HOT 1
- Restrictions for openType
- ??
- _Originally posted by @mmtayyar in https://github.com/CVEProject/cve-schema/issues/283_
- Have guidance for when to use unschematized models, and what patterns we have available for unschematized models
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 api-guidelines.