0

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

student18
  • 538
  • 8
  • 26
  • I can't help you without knowing what the URL looks like. – mjwills Nov 12 '18 at 09:02
  • tags at end of URL is for matching the corresponding controller, I don't want to remove the tags parameter from my action. As I said above I need to know how a possible URL ending can look like for passing a complex type.. – student18 Nov 12 '18 at 10:42
  • the url isn't containing tags at its end because that is the point I need to know how to implement – student18 Nov 12 '18 at 10:42

0 Answers0