As stated in the Retrofit documentation above the @Query
annotation:
Passing a List or array will result in a query parameter for each non-null item.
As of now my call looks something like this:
@GET("questions")
Call<List<QuestionHolder>> getQuestionsExcludingTheSpecified(
@Query("exclude_ids") long[] excludedQuestionIds
);
This works but results in fairly long URLs quite fast.
E.g. for excludedQuestionIds = new long[]{1L, 4L, 16L, 64L}
the request URL already will be /questions?exclude_ids=1&exclude_ids=4&exclude_ids=16&exclude_ids=64
.
Is there an easy way to exchange this behaviour resulting in arrays formatted as exclude_ids=[1,4,16,64]
or something similar?
What came to my mind yet was, to:
- use JsonArray as parameter, but then I need to convert every array / list before making the call
- intercept every request and compress duplicated keys
- override the built-in
@Query
decorator
Any ideas?