我正在尝试从邮递员那里调用 WEBAPI。我的 AI 方法是发布的,但是当我执行它时,我得到以下错误
找到多个与请求匹配的操作:***
下面是我的代码:webapi route.config
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "Api Default",
routeTemplate: "api/{controller}/{method}/{id}",
defaults: new { id = RouteParameter.Optional }
);
//config.Routes.MapHttpRoute(
// name: "DefaultApi",
// routeTemplate: "api/{controller}/{id}",
// defaults: new { id = RouteParameter.Optional }
//);
// Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable<T> return type.
// To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
// For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
config.EnableQuerySupport();
// To disable tracing in your application, please comment out or remove the following line of code
// For more information, refer to: http://www.asp.net/web-api
config.EnableSystemDiagnosticsTracing();
}
}
API控制器:
public class MembershipController : ApiController
{
[System.Web.Http.ActionName("Upload")]
public HttpResponseMessage Upload(string employeedetails)
{
`Some Code`
}
[System.Web.Http.ActionName("BulkUpload")]
[System.Web.Http.HttpPost]
public HttpResponseMessage BulkUpload(string employeedetails)
{
`Some Code`
}
[System.Web.Http.ActionName("Transfer")]
public HttpResponseMessage Transfer(string employeedetails)
{
`Some Code`
}
}
我没有得到什么是错误的方法有不同的动作名称和路由配置也是完全限定的 api url,其中包含控制器方法和 id 作为可选参数。要识别 url 这应该足够了,但它不起作用。我错过了什么吗?
相关分类