Search code examples
c#xamarinrefit

Convert url parameters using Refit


I am using the Refit library to access my API. This is working quite good, but i have some problems using a list of enums in my url.

[Get("/track/")]
Task<IList<Track>> GetAll(int size = 20, int from = 0, [AliasAs("content-types")] IEnumerable<TrackSubType> contentTypes = null, IEnumerable<string> tags = null, string language = null);

The IEnumerable contentTypes is currently converted to:

https://website.com/track/?content-type=System.Collections.Generic.List`1[Api.Implementation.Models.TrackSubType]

I want to have it in the format:

https://website.com/track/?content-type[]=sometype

How can i achieve this?


Solution

  • My question is currently not possible with Refit without doing some workarounds. There is an issue in GitHub of Refit where this topic is covered and there is someone working on it: https://github.com/paulcbetts/refit/issues/4