ASP.NET Web API Error {"Message":"The requested resource does not support http method 'GET'."}

Updated on: March 15, 2021

When running ASP.NET Web API on your machine and getting following error, then following are the possibilities that you need modifications in your code to fix this error:

Error: {"Message":"The requested resource does not support http method 'GET'."}

You get above error when you haven't specified request type attribute on the action method (e.g. HttpGet, HttpPost, HttpPut, HttpDelete) of Web API Controller or another possibility is that you haven't configured Routing properly for controller or action method or both. Following are the possible solutions for the above error:

Solution 1:

Convert your following Web API's Action method from

public List<UserDetails> GetAllUsers()

Modify to: 

[HttpGet]
public List<UserDetails> GetAllUsers()


Solution 2: If above solution 1 does not work for your project or you have already added "[HttpGet]" attribute to your action method, but you are still getting this error, then issue is possibly with your routing specified for the mentioned action method. You can check for routing specified at the controller level as well as at the action method level.  You can change the following lines of code:

[HttpGet]
[Route("GetAllUsers")]
public List<UserDetails> GetAllUsers()

Modify to:

[HttpGet]
[Route("api/Users/GetAllUsers")]
public List<UserDetails> GetAllUsers()

OR Modify to:

[RoutePrefix("api/Users")]
public class UsersController : ApiController
{
    [HttpGet]
    [Route("GetAllUsers")]
    public List<UserDetails> GetAllUsers()
    {
        return new List<UserDetails>();
    }
}