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:-
Any help/suggestion highly appreciated. Thanks
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]
[HttpGet]
[Route("api/albums/history/")]
public IHttpActionResult GetHistory([FromUri]string type,[FromUri]int id)
{
//api stuff
}
or to hit the api via route parameters - http://localhost:50684/api/albums/history/test/1
[HttpGet]
[Route("api/albums/history/{type}/{id}")]
public IHttpActionResult GetHistory(string type,int id)
{
//api stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With