I have ASP.NET WebAPI project, which has Get API - "appointment/available" defined as follows:
using System;
using System.Web.Http;
using AppointmentScheduler;
using Microsoft.Practices.Unity;
[RoutePrefix("appointment")]
public class AppointmentController : ApiController
{
#region [ Properties ]
[Dependency]
public IAppointmentScheduler AppointmentScheduler { get; set; }
#endregion
#region [ Methods - API ]
[Route("available")]
[HttpGet]
public IHttpActionResult GetAvailableAppointments(string agentEmailId, DateTime startDate, DateTime endDate) {
try {
return base.Ok(this.AppointmentScheduler.GetAppointments(agentEmailId, startDate, endDate));
} catch (Exception exception) {
return base.InternalServerError(exception);
}
}
#endregion
}
However, on running the solution and calling the API from Fiddler as "GET" request I get following error:
HTTP 405 Error - The requested resource does not support http method 'GET'.
On sending the same request as "POST" I get HTTP - 200 response. Even though my method was never called (the breakpoint on the API method was never hit)
I looked into previous query on this issue here. But none of the answers seems to be solve my issue.
Interestingly, unless I'm crazy the exact code was working for me sometime back.
I think the issue started coming up when I tried to open the solution initially built on VS 2013 on VS 2015. I feel, only after that the solution started giving issue in both the IDEs.