Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit2 encodes Query value even when encoded=true

Using Retrofit 2.4, I'm calling an API that receives a JSON object as part of a query string such as /list?filter={"columns":"a,b,c","start":""...}

Instead of writing a converter I just use a jackson mapper to write the object as string before.

fun getReport(@Query("filter", encoded = true) request: String)

But what retrofit is doing is that it does not encode the brackets, but it does encode all the quotes, the url then becomes:

filter={%22columns%22: ...

And this is of course causing issues with the invocation.

Ideas?

like image 493
Vinicius Carvalho Avatar asked Sep 04 '25 02:09

Vinicius Carvalho


1 Answers

Use QueryMap in your functions

@QueryMap(encodeNames = true) 

more details refer Annotation Type QueryMap

like image 77
sasikumar Avatar answered Sep 07 '25 19:09

sasikumar