【问题标题】:Error 400 on Put request to a RestFull webService向 RestFul Web 服务发送请求时出现错误 400
【发布时间】:2017-10-03 08:42:06
【问题描述】:

我需要调用 Web 服务来获取一些数据,但是当我使用此代码时:

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

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

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



});

它继续向我返回错误 400...我错在哪里?

【问题讨论】:

    标签: angularjs web-services put


    【解决方案1】:

    首先检查服务是否正常,然后使用此代码

    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;
      });
    
    }); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 2016-01-06
      • 2020-08-22
      • 2012-12-01
      • 2017-05-19
      相关资源
      最近更新 更多