When using the HTTP Delete method, you cannot pass data as an argument. </p>
<p><strong>This Approach Will Not Work</strong> </p>
<p>In this scenario, passing an object would look like this:</p>
<pre><code>var cdata = {
id: 2,
lineUp: [...]
};
// This won't work
$http.delete('webapi/Data/delete, cdata)
.then(function(response) {
console.log(response);
})
.then(function(error) {
console.log(error);
});
For a truly RESTful approach, you should only need to provide the id
to the HTTP Delete
method.
Embrace RESTFul Design
var cdata = {
id: 2,
lineUp: [...]
};
// Using RESTful design
$http.delete('webapi/Data/delete/' + cdata.id)
.then(function(response) {
console.log(response);
})
.then(function(error) {
console.log(error);
});
If necessary, you can utilize the HTTP Post
method as a workaround.
Here's a Workaround
var cdata = {
id: 2,
lineUp: [...]
};
// This is a workaround
$http.post('webapi/Data/delete, cdata)
.then(function(response) {
console.log(response);
})
.then(function(error) {
console.log(error);
});