I faced the same issue.
For deleting multiple ids, it's better to use DELETE since it's the more semantically correct method for resource deletion. However, DELETE has some limitations:
DELETE does not support a request body in some browsers and HTTP clients (though in practice, most servers allow it).
POST is more flexible and universally supported, but it is semantically meant for creating or processing data, not deleting it.
Possible Approaches which I find:
- Use
DELETE with query parameters:
DELETE /users?ids=1,2,3,4
The server retrieves ids from the query parameters and deletes them.
- Use
DELETE with a request body (if supported by the server):
DELETE /items
Content-Type: application/json
{
"ids": [1, 2, 3, 4]
}
- Use
POST (if DELETE with a request body is not supported):
This approach is more compatible but less RESTful.
DELETEverb with a CRUD URL? Also, ifidsare arbitrary then you'd be best usingPOSTand passing the IDs up in the body given URLs have a maximum length.