I have a Web API setup and I want to pass a string parameter to the GetAutomation method. In Global.asax I have:
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{testName}",
defaults: new { id = System.Web.Http.RouteParameter.Optional });
RouteTable.Routes.MapHttpRoute(
name: "DefaultApiWithAction",
routeTemplate: "api/{controller}/{action}/{testName}");
}
In my AutomationController.cs, I have:
[ActionName("GetAutomation")]
[HttpGet]
public string StartAutomation(string testName)
{
//string testName = "MyTest123";
Vmware.StartAutomation("automation-server", testName);
return "Automation started for " + testName;
}
If I remove the testName parameter from StartAutomation and call:
http://localhost/api/Automation/GetAutomation
it works. If I put it back in and try
http://localhost/api/Automation/GetAutomation/Test123
it fails with a 404 error. Any idea what I''m doing wrong? Thanks, J.