I am having trouble with one of my HTTP GET controller methods in my .NET Core 2.1 backend.
The method should take an array of type Tags
as input, to return some objects which are tagged with these tags.
As far as I know it is not possible to use [FromBody]
attribute for HTTP GET, as this will always lead to an empty result.
Considering this stack link with the following closed github issue link, it should now be possible to parse complex array types using the FromQuery
attribute, am I right?
Comming back to my question, I want to ask what would be the right syntax so that an HTTP GET method can have an array of a complex type as input? This includes I don't know how the the URL must look like.
my controller method:
[HttpGet]
public ActionResult<ComplexType[]> ComplexTypesByTags([FromQuery]Tags[] tags)
{
// do some stuff with 'Tags[] tags' array
}
Tags model:
public partial class Tags
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
}
API endpoint is: http://localhost:44381/api/v1/tags