I want to pass the id
and dept
field in a DELETE HTTP request and fetch inside deleteData()
but I'm receiving null in deleteData()
for id
and dept
.
$http['delete']('webapi/Data/delete?' + cdata.id + "&&" + cdata.lineUp)
@DELETE()
@Path("/delete")
public String deleteData(@QueryParam("id") String id, @QueryParam("dept") String dept){
HTTP Delete
does not accept data as an argument.
Won't Work
Otherwise, I would pass an object like so:
var cdata = {
id: 2,
lineUp: [...]
};
// won't work
$http.delete('webapi/Data/delete, cdata)
.then(function(response) {
console.log(response);
})
.then(function(error) {
console.log(error);
});
If you wanted to be truly RESTful, you shouldn't need to pass anything to the HTTP Delete
method besides the id
.
RESTFul
var cdata = {
id: 2,
lineUp: [...]
};
// RESTful
$http.delete('webapi/Data/delete/' + cdata.id)
.then(function(response) {
console.log(response);
})
.then(function(error) {
console.log(error);
});
You can, however, use HTTP Post
as a workaround.
Workaround
var cdata = {
id: 2,
lineUp: [...]
};
// workaround
$http.post('webapi/Data/delete, cdata)
.then(function(response) {
console.log(response);
})
.then(function(error) {
console.log(error);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With