I'm building a web api where I have one resourse that must have 3 get methods as follows:
[HttpGet]
[Route("{city}/{streetName}/{streetNumber}/{littera}")]
public IActionResult GetByAddress([FromQuery]string city, [FromQuery]string streetName, [FromQuery]int streetNumber, [FromQuery]string littera)
{
var model = _availabilityService.FindByAddress(city, streetName, streetNumber, littera);
return Ok(model);
}
[HttpGet("{pointId}")]
public IActionResult GetByPointId(string pointId)
{
var model = _availabilityService.FindByPointId(pointId);
return Ok(model);
}
[HttpGet]
[Route("{xCoordinate}/{yCoordinate}")]
public IActionResult GetByCoordinates([FromQuery]decimal xCoordinate, [FromQuery]decimal yCoordinate)
{
var model = _availabilityService.FindByCoordinates(xCoordinate, yCoordinate);
return Ok(model);
}
The get method with only one parameter(pointId) is working fine since it is not seen as a query string but rather and id. However the remaining 2 methods are not distinguishable by the router in ASP.NET, it seems.
I'm really at a loss here and cannot figure out why it doesn't work. What I have been able to work out is that if I remove one of the methods the other one works fine.
Any suggestions on what I'm doing wrong?
FYI, the corresponding url:s ought to look like the following:
api/1.0/availabilities?city=Metropolis&streetName=Superstreet&streetNumber=1&littera=A
and
/api/1.0/availabilities?xCoordinate=34.3444&yCoordinate=66.3422
Thanks!