I cannot seem to pass an array of values to my Web API method for some reason. Here is my code:
[HttpGet("api/values/get/{ids}")]
public JsonResult GetValues(string[] valueIds)
{
//Do something
}
I have tried calling this via the following URLs:
- http://localhost:5001/api/values/get/?valueIds=das&valueIds=ewq
- http://localhost:5001/api/values/get/?ids=das&ids=ewq
- http://localhost:5001/api/values/get?valueIds=das&valueIds=ewq
- http://localhost:5001/api/values/get?ids=das&ids=ewq
When I call it via the following URLs, I get no 404 and the method is actually called, however, the array is empty:
- http://localhost:5001/api/values/get/valueIds=das&valueIds=ewq
- http://localhost:5001/api/values/get/ids=das&ids=ewq
I have also tried adding the Attribute [FromQuery] to the front of my parameters in the method signatures like this:
public JsonResult GetValues([FromQuery]string[] valueIds)
I cannot seem to get it to work even though every tutorial out there says it should. Ripping my hair out here.