[HttpGet("CalibrationModelFile/{networkID:int}/{ConstituentID:int}/{values:double[]}/UpdateLimits")]
I have to send in an array of doubles obviously. My function works fine if I pass in individual values like:
{value1: double}/{value2: double}/ etc
But that is pretty lame and I can have a lot of values to send. When I try to place the call, the server gets the following error (the relevant part):
Sorry for the tiny image.
I can't find documentation anywhere that helps. Any ideas?
Thanks in advance, Chuck ("Yogi")
Double[]
isn't one of the accepted types for constraint. The important thing to note is that these are only constraints, not true type specifiers. We can just say we want values
, and specify in the arguments that it is a double[]
. See the documentation for a list of built-in constraints.
You can do this most easily by using the FromRoute
attribute. Specify the type in the arguments rather than the route.
[HttpGet]
[Route("CalibrationModelFile/{networkID:int}/{ConstituentID:int}/{values}/UpdateLimits")]
public IActionResult GetThing([FromRoute(Name = "values")] double[] values)
{
return new OkObjectResult(values);
}
Then call like
http://localhost:5000/api/CalibrationModelFile/12/13/5,2,3,4/UpdateLimits
Returns
[
5234
]