如何使用带有 Okhttp3 的 retrofit2 禁用 URL 编码

How do i disable URL encoding using retrofit2 with Okhttp3

我有一个来自 https://developers.google.com/places/web-service/search.

的简单 Google Places 查询字符串

以下 URL 显示搜索悉尼附近的餐馆。

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

但是我的 retrofit2 和 Okhttp3 编码如下:

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

"%2B" 替换每次出现的 "+"。我希望停止这种情况。

请问我该如何实现?

编辑

我刚刚读完 Github 问题 https://github.com/square/retrofit/issues/1407 ,没有找到答案

这对你有用吗?

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

encoded =true 应该告诉 retrofit 参数已经编码。