Reputation: 47290
Controller looks like the following, the get
works ok, but when a post
is called recieve the referenced :
[ActionName("import")]
public void PostImport([FromBody]string file = "myString")
{}
[ActionName("something")]
public void PostSomething()
{}
[ActionName("bool")]
public Boolean GetBool()
{}
routes register like below :
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "ControllerAndAction",
routeTemplate: "api/{controller}/{action}"
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
The request I am using is this :
curl -H "Content-Type: application/json" -d '{"file":"myOtherString"}' http://localhost:6
1393/api/admin/import
Upvotes: 0
Views: 1144
Reputation: 3002
The URL /api/admin/import matches two different routes.
It matches DefaultApi with a controller of "admin" an id of "import".
It also matches ControllerAndAction with a controller of "admin" and action of "import".
So it can't work out which route to use
Upvotes: 1