Ionic native http POST is not sending data to the server

Hi, I ran into the one problem. POST is not sending data to the server. GET is working fine. Below is my code:-

post(user){

let bodynow = {

“email_id”: “aa@gmsd.sdf”,

“mobile”:“9978897989”,

“first_name”: “dfdf”,

“last_name”: “ghgfh”,

“user_title”:“MS”,

“country_code”: “91”

}

const url =

https://www.allevoyage.com/index.php/hotels_android/update_profile”;

this.http.setDataSerializer(“json”);

this.http

.post(url, bodynow,headers)

.then(data => {

console.log(data,data.url);

})

.catch(err => {

console.log(err);

});

}

cordova-plugin-advanced-http version:-2.0.1

ionic-native/http version:-4.17.0

“cordova-ios”: “4.5.5”.

I’m gettng the status as 200 with no result found error, when I call from postman, i’m getting the data. So its not issue with server side code. Anyone tell me where I went wrong.

Hi asmihajs,

I experience the same problem. Have you found a solution?

Best

Andrey

How about you post some of YOUR code, with details of your environment etc etc and maybe someone can give YOU specific advice?

Hi Geoff,
very appreciate. See below.
My case that works in postman without any problem. Authorization api request works as well. I use http native.


Output with status 200, but with empty result:



The same issue for non-authorization post call.

Am I missing anything? I assume that it is a headers issue.

Best

Andrey

One more point here. Test http get request works:

fakeHTTPGET() {

this.http.get('https://jsonplaceholder.typicode.com/todos/1',{},{})
    .then(data => this.Fake = JSON.stringify(JSON.parse(data.data)))
    .catch(err => this.Fake = err);

Result:
image

My environment:

                                                                                                                              
Ionic:                                                                                                                        
                                                                                                                              
   Ionic CLI                     : 5.4.6                                                                                      
   Ionic Framework               : @ionic/angular 4.11.5                                                                      
   @angular-devkit/build-angular : 0.801.3                                                                                    
   @angular-devkit/schematics    : 8.1.3                                                                                      
   @angular/cli                  : 8.1.3                                                                                      
   @ionic/angular-toolkit        : 2.0.0                                                                                      
                                                                                                                              
Cordova:                                                                                                                      
                                                                                                                              
   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)                                                                              
   Cordova Platforms : android 8.1.0                                                                                          
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 7 other plugins)         
                                                                                                                              
Utility:                                                                                                                      
                                                                                                                              
   cordova-res : 0.8.0 (update available: 0.8.1)                                                                              
   native-run  : 0.2.9                                                                                                        
                                                                                                                              
System:                                                                                                                       
                                                                                                                              
   Android SDK Tools : 26.1.1 (C:\Users\Dino\AppData\Local\Android\Sdk)                                                       
   NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)                                                            
   npm               : 6.4.1                                                                                                  
   OS                : Windows 10