Is there anything non-RESTful about providing parameters to a HTTP DELETE request?
My scenario is that I'm modelling the "Are you sure you want to delete that?" scenario. In some cases, the state of the resource suggests that the requested delete may be invalid. You can probably imagine some scenarios yourself where confirmation of a delete is required
The solution we have adopted is to pass a parameter to the delete request to indicate that it's ok to proceed with the delete ("?force_delete=true")
e.g.
DELETE http://server/resource/id?force_delete=true
I believe that it's still restful since:
(a) The semantics of DELETE are not being changed - the user can still send a normal DELETE request but this may fail with 409 and the body of the response will explain why. I say may fail because (for reasons not worth explaining) on some occasions there is no reason to prompt the user.
(b) There's nothing in Roy's dissertation to suggest that it's against the spirit of REST - why would there be since HTTP is only one implementation of REST so why would passing HTTP parameters matter
Can someone point me at a definitive statement that nails the reason why this isn't RESTful?
On a related question, if the user does not specify force_delete then I'm returning 409 Conflict
- is that the most appropriate response code?
Follow up
After some further research, I think that adding parameters to the DELETE may violate several principles.
The first is that the implementation possibly violates the "Uniform Interface" (see section 5.1.5 of Roy's dissertation
By adding 'force_delete' we're adding an additional constraint onto the already well defined DELETE method. This constraint is meaningful only to us.
You could also argue that it violate the "5.1.2 Client-Server" since the confirmation dialogue is really a UI concern and again not all clients will want to confirm deletion.
Suggestions anyone?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…