Alexei
Alexei

Reputation: 15656

How decode urt params

In my android project I use Retrofit 2

@GET("/transfers/tunnels")
    fun getTunnelsList(
        @Query("destination[id]") destinationId: String,
        @Query("amuunt") amount: Double,
        @Query("currency") currency: String
    ): Call<List<Tunnel>>

And here result:

-> GET http://my_ip/transfers/tunnels?destination%5Bid%5D=9eb5fd41-16f8-430c-91b7-a69ad1fd4c89&amuunt=4.0&currency=EUR http/1.1

But I need param with name destination[id]

smt like this:

-> GET http://my_ip/sends?preferred_agent[id]=12345&amuunt=12.1&currency=USD&receiver[id]=receiverID_guid&destination[id]=destinationId_guid&contract[id]=contractId_guid&is_ready=false 

How I can do this?

Upvotes: 0

Views: 62

Answers (1)

Andrei Tanana
Andrei Tanana

Reputation: 8422

You can set encoded parameter of Query annotation to true. Then it'll work as intended

@GET("/transfers/tunnels")
fun getTunnelsList(
    @Query("destination[id]", encoded = true) destinationId: String,
    @Query("amuunt") amount: Double,
    @Query("currency") currency: String
): Call<List<Tunnel>>

Upvotes: 1

Related Questions