Quantcast
Channel: Question and Answer » web-services
Viewing all articles
Browse latest Browse all 136

How to handle business rules with a REST API?

$
0
0

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


Viewing all articles
Browse latest Browse all 136

Trending Articles