We're trying to re-engineer our SOAP API to a RESTful one (using ASP.NET Web Api).
I know the question of how to replace RPC-style calls with REST comes up a lot but I still haven't found anything that quite gets me where I want. It may be a failure of imagination or a fundamental misunderstanding of REST principles (I'll let you be the judge of that!)
I've created an example below which roughly maps to the kind of thing I'm trying to achieve.
Suppose we have a resource which I'll call Booking
GET .../Bookings/Booking/1
And we have a requirement to cancel this booking which previously would have been modelled with something like.
...CancelBooking(1, Reasons.NoLongerRequired)
So it's the booking ID and a reason code.
Or we may need the ability to cancel multiple bookings in a single request.
...CancelBooking("1,2,3", Reasons.NoLongerRequired)
(A little crude but I'm trying to keep the example simple!)
How would we best model this in a RESTful architecture?
One suggestion is that we have a resource called something like a CancellationRequest and we POST one of these to the server?
POST .../Bookings/CancellationRequest
{
"BookingIDs" : "1,2,3",
"CancellationReason" : "NotRequired"
}
Perhaps this would do the processing and then return a redirect to the cancelled Booking(s)?
But I don't know if this is the best approach in terms of REST.
Can anyone advise?