我有一个来自 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/