How to use ionic native HTTP to perform a post with body and header

thank you it helped.

Thanks. You are really great.

Thanksssss. You saved my day. Its works fine.

thx, it works fine!!

unable to find setDataSerializer method.
coming as undefined.

Dude. This was it. Thanks so much!

1 Like

Its kinda lame to ask but could you provide example for sending a data using post request to a mysql server, i cant find any example using ionic native http in sending data to a server. thanks

1 Like



You have no idea how long it took me to find that missing piece of this extremely frustrating puzzle.


thanks alot for such support

I just changed as you said but for utf8 and it worked perfectly for application/x-www-form-urlencoded

thank you!

this.http.setDataSerializer('json');'url here', {"title": "something"}, {"Content-Type": "application/json"})
    .then(data => console.log(data))
    .catch(error => console.log(error));

this works, but the backend don’t receive any data…
my php prints the var_dump($_POST) as array(0) {}
any thoughts?

I was searching a lot about this. Your tip works great. I would like to draw ionic team attention those who make the documentation most of the docs are pretty basic. it dose not explain how some functions works, we could save a lot of time if what our friend has written was documented in the docs.

thanks for your contribution

1 Like

below code use to receive data
$postdata = json_decode(file_get_contents(“php://input”),true);

The fix still WORKS!! After 2 years. Thanks.

It worked for me, thanks a ton.

Hello, I tried your solution but it’s not working ! here’s my code :

this.http.setDataSerializer(‘json’);‘’, { “loginName”: FormLogin.username ,"&password" : FormLogin.password,“output” : “json”} ,{“Content-Type”: “application/json”} )
.then(data => console.log(data))
.catch(error => console.log(error));

Please Help me

Remove & symbol in you r code
And check console log

Thank you a billion times. I didn’t realize it was this simple

Hi, I need help in resolving this issue. I’m facing issue when doing POST request to get the access token in IOS. Whereas it works fine in Android.

const bodyParams = {‘client_id’:clientId,‘client_secret’:secret,‘grant_type’:‘authorization_code’,‘code’:tokenOrCode};

const httpResponse = await, bodyParams, {“Content-Type”: “application/json”});

{“error”:“invalid_client”,“error_description”:“FBTOAU204E An invalid secret was provided for the client with identifier: ‘’.”}

Note: The above code works without any issues in Android.