I'm trying to get a simple WebAPI project working.
I have a WebApiConfig.cs with this:
config.Routes.MapHttpRoute(
name: "cap-getvehicleoptions",
routeTemplate: "api/{controller}/{action}/{type}/{capid}",
defaults: new { controller="Cap", action="GetVehicleOptions" }
);
Then this controller:
public class CapController : ApiController
{
public string GetVehicleOptions(string type, int capid)
{
var response = CapService.GetVehicleOptions(type, capid);
response.Url = string.Format("/api/cap/getvehicleoptions/{0}/{1}", type, capid.ToString());
return Serialization.Serialize(response);
}
}
When I run try this: http://localhost:62924/api/cap/GetVehicleOptions/car/55555/
I get:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:62924/api/cap/GetVehicleOptions/car/55555/'.","MessageDetail":"No action was found on the controller 'Cap' that matches the request."}
I wondered if it's because of the int capid property, but tried string and that didn't help.
thanks