Tosin Onikute
Tosin Onikute

Reputation: 4002

How do i disable URL encoding using retrofit2 with Okhttp3

I have a simple Google Places Query string from https://developers.google.com/places/web-service/search.

The following URL shows a search for restaurants near Sydney.

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+Sydney&key=YOUR_API_KEY

But then my retrofit2 & Okhttp3 encodes it like this below:

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants%2Bin%2BSydney&key=YOUR_API_KEY

Replacing every occurrence of "+" with "%2B". And i wish to stop this.

How do I achieve this please?

Edit

I just finished reading the Github issue https://github.com/square/retrofit/issues/1407 , No answer found

Upvotes: 5

Views: 2664

Answers (1)

j2emanue
j2emanue

Reputation: 62519

does this work for you ?

Call<List<Articles>> getArticles((@QueryMap(encoded=true) Map<String, String> options); 

encoded =true should tell retrofit that the paramter is already encoded.

Upvotes: 4

Related Questions