What would be the best way of receiving IEnumerable
as a URI-parameter for a GET endpoint in .NET Core 3.x
In deeper context: What I want to do is filtering out data depending on a number of GUIDs´.
So far I've got
[HttpGet]
public ActionResult Get(int allowedMissing, IEnumerable<Guid> ids)
.
.
.
Im calling the endpoint using Postman as such:
/endpoint?allowedMissing=2&ids=cab0cfcb-8eb2-4313-8064-e7b0841d4f8a&ids=b2b944c2-6b4a-4c32-9a2f-472b891e4843
This results in a 415 Unsupported Media Type
without hitting any breakpoints inside the controller.
Ok, so default for receiving IEnumerable
in an Action seems to be in body
and will require decorating the parameter with FromQuery
if sent as query.
Changing to this solved my problem:
[HttpGet]
public ActionResult Get(int allowedMissing, [FromQuery] IEnumerable<Guid> ids)
.
.
.