I work on my web api project. I get error 404 when I try to pass date variable in get request to web api method.
Here is web api method:
[HttpGet]
[Route("ReportDetailed/{clientId}/{date}")]
public IHttpActionResult ReportDetailed(int clientId, DateTime date )
{
return Ok();
}
And here how I try to access to the function above(row from URL):
http://localhost/station/api/Reports/ReportDetailed/12/Wed%20Jun%2001%202016%2000:00:00%20GMT+0300%20(Jerusalem%20Daylight%20Time)
where clientId is 12 and date is parsed javascript date object:
/Wed%20Jun%2001%202016%2000:00:00%20GMT+0300%20(Jerusalem%20Daylight%20Time)
when I remove from URL above the parsed Date object and date parameter from web api function it works perfect (so I guess the problem with date object).
Any idea why I get error 404 when I try to pass object in URI?
/ReportDetailed/12/2016-06-06? Does that work? If so, it's the model binder for date not recognising your date - you could use a string param and parse it in your action (throwing an exception if you can't parse it)