I'm in a confused trouble with AngularJS and my REST API (Java). I've created a tree-view-drag-drop directive, it has a function to select its items and then delete them, but when I perform a DELETE action using $resource, AngularJS overrides or ignores the request body that is where I send the items of my selection array, how can I solve it? Is there any other patterns that I can use? Maybe some modification in API... or I don't know I'd like some suggestions about this problem and how to solve in the best way both in backend and frontend.
UPDATE
JSFiddle: http://bit.ly/1QmG83Z
Perhaps the best approach should be creating a POST request, where you would pass your array, and then you could treat the delete atomically:
Service
Call
REST method example
Also, take a look at this post for further enlightenment.
Well, all the ideas you gave me were great, and helped me to reach a solution, but reading all the answers and other topics the best solution that I found was to group all ID's in a single string separated by spaces, then I pushed to the path variable, and made a DELETE request as a single resource. Then, my endpoint will split the "combined-resource" and retrieve each of them separately to perform a delete action.
As far as I know, HTTP method
DELETE
doesn't take a body.You would need an endpoint in your api to treat this "batch" request using an array in body
Or you could also launch a DELETE request on each resource via Angular without any body