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

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

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.

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…’

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

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.

I had the same issue.

For anyone who has the same problem just set this

import { HTTP } from '@ionic-native/http';

constructor( private httpCordova: HTTP){}

this.httpCordova.setDataSerializer('json');

before HTTP call’s