I have the following url:
localhost/api/machine/somecode/all
I have the following controller:
public class MachineController : ApiController
{
public IEnumerable<Machine> Get()
{
return new List<Machine>
{
new Machine
{
LastPlayed = DateTime.UtcNow,
MachineAlertCount = 1,
MachineId = "122",
MachineName = "test",
MachinePosition = "12",
MachineStatus = "test"
}
};
}
public IEnumerable<Machine> All(string code)
{
return new List<Machine>
{
new Machine
{
LastPlayed = DateTime.UtcNow,
MachineAlertCount = 1,
MachineId = "122",
MachineName = "test",
MachinePosition = "12",
MachineStatus = "test"
}
};
}
}
and the following routes:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "MachineApi",
routeTemplate: "api/machine/{code}/all"
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
but for some reason it's not resolving - any glaringly obvious reason why?