Ionic Native HTTP Client delete function not works, it doesn't send the parameters


#1

Hi, I’m trying to do a delete request to my api but it returns that the parameters are missing:

this.http.delete(path, data,headers)
.then(response => {
return JSON.parse(response.data);
})
.catch(error => {return this.handleError(error)});
It seems that delete function not sends the body data. The same request with postman works fine.
With post, and put there are not problems, What would be the problem?

Info:

Android platform: 6.4.0
Ionic version 3.9.2
Ionic native http: 4.5.3
Http Plugin version: 1.11.0


#2

Hi, @Hanzo

Try this:

return new Promise((resolve, reject) => {
		this.http.delete(path, data,headers)
        .subscribe(res => {
			resolve(res.json());
		},err => {
			reject(err.json());
		});
});

Thanks.


#3

Sorry but I dont see how your answer would solve my problem. Is not a problem of how do the promise, on the original code i return the promise generated to other method with ‘return this.http.delete…’


#4

Hanzo, got any solution for this, as im hitting the same issue


#5

Your backend is trying to rely on undefined behavior.

Quoth RFC 2616:

if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request.

There are no defined semantics for entity-body in DELETE requests. The URL uniquely and completely defines what DELETE is to do.