我有一个Backbone.js应用程序,它调用我的一个WEB API自定义POST方法。下面是代码到我的自定义后Fiddler - asp.net web api自定义POST
WebApiConfig.cs
config.Routes.MapHttpRoute
(
name: "UserAdministrationApi",
routeTemplate: "api/{controller}/PostUserInfo/{EmployeeDTO}",
defaults: new
{
EmployeeDTO = RouteParameter.Optional,
controller = "UserAdministration",
action = "PostUserInfo",
});
控制器
[HttpPost]
[ActionName("PostUserInfo")]
public HttpResponseMessage PostUserInfo(EmployeeDTO value)
{
// handling POST
}
EmployeeDTO
public class EmployeeDTO
{
public bool masAccess { get; set; }
public bool reportAccess { get; set; }
public string name { get; set; }
public string office { get; set; }
}
当我尝试甚至去之前测试这提琴手用Backbone.js代码测试它,我得到500内部错误。不知道什么是错的
//提琴手TEST
POST : http://localhost:56501/api/useradministration/PostUserInfo
Request Body
{
masAccess:"true"
reportAccess:"false"
}
感谢您的帮助
你用来测试这个的请求是什么?另外'PostUserInfo'中的代码可能是相关的。 – Andrei
值参数本身被设置为空。 – Harish
这正是你如何用小提琴进行测试的吗?由于默认情况下,fiddler以查询字符串的形式期望body:'masAccess = true&reportAccess = false'。 – Andrei