In my Angular app, I need to send an $http.delete
request this route /projects/:id/activityTypes
(note it does not end with an activity type id) passing a body with the following format:
[{"id": 2}]
This is to allow batch delete operations by sending multiple objects within the array.
Testing the route above with Rest Web Service Client I get a 200, OK
status so the route is already implemented and working fine, I just need to implement it in my Angular app.
Now, I've checked this previous post which has a very similar question and learned that angular's $http.delete
does not send a body in the request by default, but that:
[it] does allow us to supply a config object as the second parameter, through which we can get access to the 'data' property.
So I tried what was suggested and sent a config object in my request:
return $http.delete('projects/' + projectID + '/activityTypes', {data: [{id: 2}]})
However, it does not work. It seems that although I am sending this config object, I am still not sending a body.
How can I actually pass a body to my $http.delete
route?
EDIT: Here is what the server is logging when I send the $http.delete
request above:
The data appears to have been sent, but I get this console error which I don't get when using the Rest Client:
Object {data: "Json not valid to remove activity type from Project", status: 400, config: Object, statusText: "Bad Request"}