I have this Web API method:
[Route("api/[controller]")]
[ApiController]
public class SubjectsController : ControllerBase
{
[HttpGet("children")]
public IActionResult GetAllFromChildren([FromQuery]int[] childrenIds)
{
// omitted for brevity
}
}
I'm trying to call this via Ajax passing in an query string but I can't seem to get it to work. My Ajax call looks like this:
$.ajax({
url: "/api/subjects/children?childrenIds=1&childrenIds=2&childrenIds=3",
method: "GET",
contentType: "application/json; charset=utf-8"
})
The method is called but it the int array does not get populated. What am I doing wrong?