Http Post not working

Hi guys, I am doing an app with http request. I already have a Rest Api for POST/GET and as I use the get i works already. Now my problem is the post method, if I use test app for my post api(postman) it works but when I use it in my ionic app it always return to me something wrong with posting data… Hope you help me with this one.

Here is my code in my Http Post method :

$http.post("url(host)", 
          { data: { 
            first_name: $scope.data1.fname,
            last_name: $scope.data1.lname,
            username: $scope.data1.email,
            password: $scope.data1.pass,
            skype_id: $scope.data1.skype,
            location_address: $scope.data1.city,
            gender: $scope.data1.gender,
            birthday: $scope.data1.birthday,
            heading: $scope.data2.heading,
            about: $scope.data2.descriptions,
            marital_status: $scope.data2.status,
            occupation: $scope.data2.work,
            height: $scope.data2.uheight,
            hair_color: $scope.data2.uhair,
            body_type: $scope.data2.ubody,
            nationality: $scope.data2.unation,
            ethnicity: $scope.data2.uethni,
            english_ability: $scope.data2.uenglish,
            spanish_ability: $scope.data2.uspanish,
            living_situation: $scope.data2.uliving,
            willing_to_relocate: $scope.data2.urelocate,
            match_gender: $scope.data2.umatchgender,
            match_min_age: $scope.data2.uagefrom,
            match_max_age: $scope.data2.uageto
          }
        })
          .success(function (response) {
           console.log(response);
          })
          .error(function (response) {
            console.log(response);
            console.log("Error in submitting");
          });

Try taking the outer brakets {} from around your data object.

$http.post("http://dev.colombiandreamdate.com/api/v1/createuser", 
          data: { 
            first_name: $scope.data1.fname,
            last_name: $scope.data1.lname,
            username: $scope.data1.email,
            password: $scope.data1.pass,
            skype_id: $scope.data1.skype,
            location_address: $scope.data1.city,
            gender: $scope.data1.gender,
            birthday: $scope.data1.birthday,
            heading: $scope.data2.heading,
            about: $scope.data2.descriptions,
            marital_status: $scope.data2.status,
            occupation: $scope.data2.work,
            height: $scope.data2.uheight,
            hair_color: $scope.data2.uhair,
            body_type: $scope.data2.ubody,
            nationality: $scope.data2.unation,
            ethnicity: $scope.data2.uethni,
            english_ability: $scope.data2.uenglish,
            spanish_ability: $scope.data2.uspanish,
            living_situation: $scope.data2.uliving,
            willing_to_relocate: $scope.data2.urelocate,
            match_gender: $scope.data2.umatchgender,
            match_min_age: $scope.data2.uagefrom,
            match_max_age: $scope.data2.uageto
        })
          .success(function (response) {
           console.log(response);
          })
          .error(function (response) {
            console.log(response);
            console.log("Error in submitting");
          });

do yourself a favor and construct the object before you pass it to the post. This is bad for maintenance and readability

I will make it simple. All I want to do is to make the post work like this code:

$http.post("url(host)", 
          { data: {
            first_name: $scope.data1.fname,
            last_name: $scope.data1.lname,
            username: $scope.data1.email,
            password: $scope.data1.pass,
            skype_id: $scope.data1.skype,
            location_address: $scope.data1.city,
            gender: $scope.data1.gender,
            birthday: $scope.data1.birthday
           }
        })
          .success(function (response) {
           console.log(response);
          })
          .error(function (response) {
            console.log(response);
            console.log("Error in submitting");
          });

But sadly it is not working…

As I study for my problem, I try to get the response (first_name for example) and it shows me null or blank… I guess that my data are not pass correctly to the api…

You can test your API first in POSTMAN or https://www.hurl.it/ and then try in $http.post

I already solve this… by letting the header to be in xxx-urlencoded… btw thanks for all the help