I'm trying to understand the principles of building REST HTTP API's, and I'm having troubles with HTTP response codes. I've read this article and I still cannot understand which code the REST API should output if the request cannot be successfully completed due to some restrictions enforced by complex business logic.
For example, an online shop API is exposing a method for adding an item into the cart, and the shop manager decided to enforce a few rules regarding this:
- products of categories A and B cannot be added to the same cart
- the total discount amount for all products in the cart cannot exceed $10
- products of category A cannot be added to the cart on Mondays
If any of these rules would be violated after adding a new item to the cart, I can send JSON responses like { "Result": "Failed", "Reason": "TotalDiscountCannotExceed10Dollars"}, etc, but what kind of HTTP status code sould I send along with the response?