How to handle business rules with a REST API?
- by Ciprio
I have a REST API to manage a booking system
I'm searching how to manage this situation :
A customer can book a time slot :
A TimeSlot resource is created and linked to a Person resource. In order to create the link between a time lot and a person, the REST client send a POST request on the TimeSlot resource
But if too many people booked the same slot (let's say the limit is 5 links), it must be impossible to create more associations.
How can I handle this business restriction ? Can I return a 404 status code with a JSON response detailing the error with a status code ?
Is it a RESTFul approach ?
EDIT :
Like suggested below I used status 409 Conflict in addition to a JSON response detailing the error