I am creating a REST API. in fact, I understand the general guidance and rule.
But I have a problem with the DELETE method, because I need to send data by body in the request, which the DELETE method will ignore the body.
If you ask what data forces me to send it to the body using the DELETE method, these are the "url" and some other parameters. Of course, "url" has an id in the database, so I can use DELETE without problems, for example DELETE https://api.example.com/content/url:url_id . But instead of passing the identifier, I decided to pass it to myself and other parameters. my business logic and requirement make me pass the url, not the id in the DELETE method.
therefore, after reading, I also find some blocking of the DELETE and PUT proxy. and also the HTML form only supports GET and POST methods.
I'm starting to think that it is better to use GET and POST in my REST API. so that I can POST user to delete both an object or resource like this:
POST /content/delete/url Body : url : xxxx param1 : xxxx param2 : xxx
But the REST API Design rulebook, O'reilly, page 18 says
"HTTP request methods should be used to indicate the CRUD function is running."
The following anti-patterns illustrate what not to do:
GET /deleteUser?id=1234 GET /deleteUser/1234 POST /users/1234/delete
after searching and reading again, I came up with some solution
using X-HTTP-Method-Override
using api method name, such as flickering (api.flickr.com/services/rest/?method=flickr.collections.getInfo) and mailchimp(api.mailchimp.com/1.3/?method=campaignDelete)
It seems to me that I like solution 1 to use the "X-HTTP override method". What do you think?
Google seems to be using an X-HTTP override method, will respond to this https://developers.google.com/gdata/docs/2.0/basics
Label name Flicker and Mailchimp, as in solution 2