I have checked some number of links to get understanding the cause of the error but not fixing my issue.
I am trying to access WebAPi action from Postman but getting the below error.
"message": "No HTTP resource was found that matches the request URI 'http://localhost:50684/api/albums/history'.",
"messageDetail": "No type was found that matches the controller named 'album'."
My API.
[Authorize]
public class AlbumsController : ApiController
{
[HttpGet]
[Route("api/album/history/")]
public BaseTO GetHistory(string type,int id)
{
//api stuff
}
}
I tried with api/album/history/{anything}
While making call from Postman I am passing:-
- Authorization Token
- Type
- Id
Any help/suggestion highly appreciated. Thanks
Your Code should be like this:
and your call from Postman should be like this and make sure your method in Postman is GET:
http://localhost:50684/api/album/history?type=test&id=1
hope it will help you.
I had the same problem I just changed this :
AllowInsecureHttp = true
Have you enabled attribute routing in api config?
config.MapHttpAttributeRoutes();
With your current route, you should hit it via query string
http://localhost:50684/api/albums/history?type=test&id=1
and decorate the parameters with[FromUri]
or to hit the api via route parameters -
http://localhost:50684/api/albums/history/test/1