1

We are new to angular js.

We tried http request using $http.get it is working fine. But in post request it is creating an issue, it comes to success and show bad parameter error code 103.

Same we have tried in ajax request using $.ajax({}), and it is working fine.

I have also paste my code.

Can anyone help us out?

mainApp.controller('registrationCtrl', function($scope, $location, $http) {
    $scope.registration = function() {
        console.log("registration called");
        var ws_url = "http://apparelinindia.com/selfiestandoff/WebServices/register";

        var request = $http({
            method: "post",
            url: ws_url,
            data: {
                user_email: $scope.email,
                user_password: $scope.password
            },
            dataType: 'json',
            headers: {
                'Content-Type': 'application/json'
            }

        });
        request.success(function(data) {
            console.log("Success" + data);
        });
        request.error(function(error) {
            console.log("Success" + JSON.stringify(error));
        });
    };
});
2
  • Tried with method: "POST" instead? Commented Sep 16, 2015 at 12:18
  • And remove dataType: 'json' Commented Sep 16, 2015 at 12:20

3 Answers 3

1

You can use http Post in following way:

  var request = $http.post(ws_url, {
        user_email: $scope.email,
        user_password: $scope.password
    });
Sign up to request clarification or add additional context in comments.

Comments

1

The name of the http method should be written in uppercase. Also, the property datatype is not awaited by $http, you should remove it:

var request = $http({
     method: "POST",
     url: ws_url,
     data: {
         user_email: $scope.email,
         user_password: $scope.password
     },
     headers: {
         'Content-Type': 'application/json'
     }
});

Note, in the above call to $http you are setting the header 'Content-Type': 'application/json'. But this header is automatically injected by $http (see $http documentation), therefore you can remove it, and use the short syntax:

var request = $http.post(ws_url, data);

with data equals to:

{
    user_email: $scope.email,
    user_password: $scope.password
}

Comments

0

Are You Getting this error ??

{"status":false,"error":{"code":"103","message":"Required Parameters not found"}}

If Yes, Its Not your Problem Contact the Web service provider.

Ask him to give the valid parameter

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.