Alessandro Pierro Alessandro Pierro - 1 year ago 157
AngularJS Question

Error 400 on Put request to a RestFull webService

I need to call a Web Service to get some data, but when i use this code :

app.controller('Hello', function($scope, $http) {

var config = {
headers: {
"loginName": 'opzudecche',
"password" : "****"
}
};

$http.put("WEBSERVICEURL", config).then(function(response) {
$scope.greeting = response.data;
});



});


It continues to return me an error 400... where I'm wrong ?

Answer Source

first check service is working then use this code

var app = angular.module('Hello', '$http', []);
app.controller('myCtrl', function($scope, $http) {

  $http({
    method: "PUT",
    url: "WEBSERVICEURL",
    headers: {
      'loginName': 'opzudecche',
      'password': "****"
    },
  }).then(function mySuccess(response) {
    $scope.greeting = response.data;
  }, function myError(response) {
    $scope.error = response.data;
  });

}); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download