javascript PUT方法请求有效载荷形成问题

时间:2019-06-21 19:32:13

标签: javascript json put

Am在coffeeScript中请求更新数据库中的现有值。正在使用以下有效负载构成一个PUT请求,并得到bad request error

请在下面找到我的有效载荷。

{  
   "thresholdValue":[  
      {  
         "businessTypeCode":"PARTS",
         "businessTypeName":"parts",
         "roleName":"System Admin",
         "roleCode":"SYSTM_ADMIN",
         "thresholdValue":"123"
      },
      {  
         "businessTypeCode":"PARTS",
         "businessTypeName":"parts",
         "roleName":"Dealer (Read-only)",
         "roleCode":"DLR_RD_ONLY",
         "thresholdValue":100
      },
      {  
         "businessTypeCode":"PARTS",
         "businessTypeName":"parts",
         "roleName":"Dealer",
         "roleCode":"DLR",
         "thresholdValue":100
      }
    ]
}

userDeactivationThresholdService.coffeeScript

ThresholdValue = $resource('userThresholdValues/update-threshold-value', {},{usage:{method:'PUT'}})

updateThresholdValue: (updatedThresholdValue, onSuccess) ->
   console.log("Update Threshold Values in Service")
   console.log(updatedThresholdValue)
   ThresholdValue.usage({thresholdValue: updatedThresholdValue}, onSuccess)

请找到我的控制器类文件(coffeeScript)

$scope.saveChanges = ->
    console.log("update threshold values")
    console.log($scope.thresholdValue)
    return if !$scope.userDeactivationThresholdForm.$valid
    $scope.editingInProgress = false
    userDeactivationThresholdService.updateThresholdValue($scope.thresholdValue, thresholdValueUpdatedSuccessfully)

我正在获得400 bad request error

0 个答案:

没有答案