Send Angular $http.delete With Body
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 f
Solution 1:
try this:
$http({
method: 'DELETE',
url: 'projects/' + projectID + '/activityTypes',
data: [{id: 2}]},
headers: {
'Content-type': 'application/json;charset=utf-8'
});
Solution 2:
@Renato's approach will work, but so would the $http.delete(...)
approach, with a little tweaking. By including the data
element in the request options, you do pass along data to the server, and you can confirm this in your Developer's Console. However, without the appropriate Content-Type, your server may likely ignore it.
The following should work:
return$http.delete('projects/' + projectID + '/activityTypes', {data: [{id: 2}], headers: {'Content-Type': 'application/json;charset=utf-8'}})
Credit goes to @Harshit Anand for his on another SO post.
Post a Comment for "Send Angular $http.delete With Body"