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

标签 android retrofit2 okhttp

我有一个来自 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 参数已经编码。

关于android - 如何使用带有 Okhttp3 的 retrofit2 禁用 URL 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44517709/

相关文章:

android - 改造 response.errorBody() 为空

android - 相对布局中的循环依赖错误。

android - 如何开始使用 Xamarin 6.0.1 社区版分析 Android 设备

android - 如何在不使用 Eclipse 的情况下使用 PhoneGap 和 HTML Editor 创建一个简单的应用程序?

java - RxJaxa 1 中的改造 2 可观察到的 : How to convert to RxJava 2

android - 如何在改造中使用 HashMap 发布数据?

android - Interceptor.Chain.proceed() 是线程阻塞方法吗?

android - React Native 文本输入更新很慢

android - 改造2。响应主体为空

Android - NetworkOnMainThreadException 与 okhttp websocket