So many people have asked the same question but I couldn't find a solution to my problem.
in postman when i call the 'http://localhost/api/GetById/2' i get the following error
No HTTP resource was found that matches the request URI http://localhost/api/GetById/2.
It works fine when I pass value 2 as a query string http://localhost/api/GetById/?id=2. Following is my WebApiConfig route parameter settings:-
config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); Following is my my API controller action method
[Route("~/api/GetById/")] [HttpGet] public HttpResponseMessage Get(int id) { var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(GetUsers(id)), "application/json"); return response; } Will please someone tell me what i am doing wrong here?