How do I bind a list of Guids passed on the query string for a web-api call.
I've tried comma separated list, an array, etc. but they always come up with an empty guid on the controller action
public endPoint:
public ApiResult Get([FromUri]List<Guid> listIds)
What I've tried
endpoint?listIds=78CC5308-5A3D-40C2-8D7C-3AAB0CAC618B,6DA7AFB8-D862-4861-8EA2-EE5EB9BC7C6A
endpoint?listIds=["78CC5308-5A3D-40C2-8D7C-3AAB0CAC618B","6DA7AFB8-D862-4861-8EA2-EE5EB9BC7C6A"]
All I get each time I try is a list with one element and it is the empty GUID
The right way for webapi is using the query parameter multiple times,no matter the type.
i.e:
endpoint?listIds=1234-5678&listIds=5555-4444....
The trick is to add an individual entry for each guid in the query string. So the values bind properly when I GET
endpoint?listIds=78CC5308-5A3D-40C2-8D7C-3AAB0CAC618B&listIds=6DA7AFB8-D862-4861-8EA2-EE5EB9BC7C6A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With