我试图将angularjs中的数据保存到api,但我有错误500内部服务器错误。控制器是一个数组,来自html页面的scops。 任何帮助
控制器
$scope.save = function ()
{
$scope.setup.push({
"Spec_Code": $scope.spec, "Medical_CTG": $scope.deg, "Doctor_Code": $scope.st, "Main_Serv": $scope.stypecode, "Serv_Group": $scope.sgroupcode, "Sub_Serv": $scope.sub,
"Pat_Type": $scope.patype, "Calc_Type": $scope.calcs, "Calc_From": $scope.rfrom, "Calc_Val": $scope.calcvalue, "STAFF_TYPE": $scope.stafftype,
"pricelist": $scope.selectedpricelist
})
var promisePost = Doctorssetup.save($scope.setup);
promisePost.then(function (pl) {
}, function (err) {
console.log("Err" + err);
});
console.log($scope.setup);
}
var promisePost = Doctorssetup.save($scope.setup);
promisePost.then(function (pl) {
}, function (err) {
console.log("Err" + err);
});
console.log($scope.setup);
}
API
public HttpResponseMessage save ([FromBody]Doctorssetup setup)
{
obj.ExecNonQuery(string.Format("insert into Doctor_Cont_Det (Spec_Code,Medical_CTG,Doctor_Code,Main_Serv,Serv_Group,Sub_Serv, Pat_Type,Calc_Type,Calc_From,Calc_Val,Sys_Date,STAFF_TYPE,pricelist) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')"
, setup.Spec_Code
, setup.Medical_CTG
, setup.Doctor_Code
, setup.Main_Serv
, setup.Serv_Group
, setup.Sub_Serv
, setup.Pat_Type
, setup.Calc_Type
, setup.Calc_From
, setup.Calc_Val
, DateTime.Now
, setup.STAFF_TYPE
, setup.pricelist
));
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);
return response;
}
非常感谢
答案 0 :(得分:2)
您在控制器上的功能需要一个对象,但您尝试发布一个数组。改变如下,
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(getLayoutInflater().inflate(R.layout.dialog_mainlayout, null));
AlertDialog alertDialog = builder.create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alertDialog.show();
在使用 $scope.setup = {
"Spec_Code": $scope.spec, "Medical_CTG": $scope.deg, "Doctor_Code": $scope.st, "Main_Serv": $scope.stypecode, "Serv_Group": $scope.sgroupcode, "Sub_Serv": $scope.sub,
"Pat_Type": $scope.patype, "Calc_Type": $scope.calcs, "Calc_From": $scope.rfrom, "Calc_Val": $scope.calcvalue, "STAFF_TYPE": $scope.stafftype,
"pricelist": $scope.selectedpricelist
});