Search code examples
asp.net-coregetasp.net-core-webapi

WebApi GET using Path and Query Parameters


I am using ASP.NET Core 1.1 API and trying to create an GET api using Path and Query parameters where:

[HttpGet]
[Route("users/{stationId}/{stationSite}")]
public IActionResult GetUsers(int stationId, int stationSiteid, [FromQuery] Paging properties)...

Paging is an Object:

public int CurrentIndex {get; set;}
public int ItemsPerPage {get; set;}

Now, I need a call like this to work:

api/users/1/2?currentIndex=1&itemsPerPage=10

The FromQuery is not working, it appears on Swagger but does not pass the correct values to API.

Am I missing anything ??


Solution

  • Using an prerelease version of Swashbuckle was causing this confusion.

    This properties were not listed on Swagger but using Postman to test the API, it worked.

    Downgrading Swashbuckle to 4.0.0 stable, worked fine.