[HttpGet]
[ActionName("all")]
public HttpResponseMessage GetAllCompetitions()
{
return Request.CreateResponse(HttpStatusCode.OK, Repository.FindAll());
}
[HttpGet]
[ActionName("GetCompetition")]
public HttpResponseMessage GetCompetitionById(long id)
{
Competition competition = Repository.FindById(id);
if (competition == null)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
return Request.CreateResponse(HttpStatusCode.OK, competition);
}
[HttpGet]
[ActionName("format")]
public HttpResponseMessage format(string postedFormat)
{
CompetitionMediaFormat format = (CompetitionMediaFormat)Enum.Parse(typeof(CompetitionMediaFormat), postedFormat, true);
return Request.CreateResponse(HttpStatusCode.OK, Repository.FindByFormat(format));
}
I am able to hit the first two get methods but when i hit "format" method am getting a 404 Not found error
Client App call
var response = await client.GetAsync("api/Competition/format/music");
Route Config
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Please let me know where am going wrong?