I have a [HttpGet]
web api method called GetCats()
that returns a collection of Cat
objects.
I added parameters skip
and take
to allow pagination.
However the requirements have increased and now there must be the possibility of complex filtering, in the case of a collection of filters in the format "PropertyName", "Value", "Type"
eg. "CatName", "Mittens", "EqualTo"
and Sort filters in the format "PropertyName", "Direction"
e.g. "CatAge", "Descending"
.
Skip and Take is also required.
When this filter object is built up it can be quite large and complex. As a result it doesn't seem to be feasible to put it into the QueryString anymore especially if there are multiple filters as you'd need a way to group them together.
I am looking for a solution - I think I could use [HttpPost]
and just post the filter but it seems wrong for a HTTP method. I'm not sure if I can somehow encode the object into the querystring and gracefully decode it or not.
Could anyone suggest a fix for this? I suspect it must be a common problem to pass complex parameters into a GET to retrieve a collection of data.