How to handle business rules with a REST API?
Posted
by
Ciprio
on Programmers
See other posts from Programmers
or by Ciprio
Published on 2014-07-22T09:48:46Z
Indexed on
2014/08/25
16:28 UTC
Read the original article
Hit count: 1676
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
© Programmers or respective owner