I wrote the following code to get a web api that accepts two parameters:
[Route("api/[controller]")]
[ApiController]
public class EventsController : ControllerBase
{
// GET: api/events/5
[Route("api/[controller]/{deviceId}/{action}")]
[HttpGet("{deviceId}/{action}")]
public IEnumerable<CosmosDBEvents> Get(string deviceId,string action)
{
try
{
return null;
}
catch(Exception ex)
{
throw (ex);
}
}
}
I try to invoke it with the following url:
https://localhost:44340/api/events/abcde/indice
but it does not work. The error is 404 , Page not found.
I also changed the code as shown below but nothing changes :
[Route("~/api/events/{deviceId}/{action}")]
[HttpGet("{deviceId}/{action}")]
public IEnumerable<CosmosDBEvents> Get(string deviceId,string action)
{
try
{
return null;
}
catch(Exception ex)
{
throw (ex);
}
}
What am I doing wrong?