I am trying to make a call as follows:
@GET(AppConstants.BASE_URL + "{category_type}/")
Call<JsonObject> callCustomFilterApI(@Path("category_type") String type,
@QueryMap(encoded = true) Map<String,String> fields ,
@Query("page") String pageNo);
But it @QueryMapmay have "&" in the data, so modify it to% 26.
There is somehow "&" does not change to "% 26".
The solution I tried:
I pass the data to QueryMap as:
private void callCustomFilterSearchPagesApi(String type, ArrayList<FilterListWithHeaderTitle> customFiltersList, int pageNumber, final ApiInteractor listener) {
Map<String, String> queryMap = new HashMap<>();
for (FilterListWithHeaderTitle item: customFiltersList) {
String pairValue;
if (queryMap.containsKey(item.getHeaderTitle())){
String oldValue=queryMap.get(item.getHeaderTitle());
String newValue="filters[" + item.getHeaderTitle() + "][]"
+oldValue+ "&"+"filters[" + item.getHeaderTitle() + "][]"+item.getFilterItem();
pairValue=newValue;
}else {
pairValue= item.getFilterItem();
}
try {
queryMap.put(item.getHeaderTitle(), pairValue);
}catch (Exception u){
LoggerUtils.crashlyticsLog(TAG,u.getMessage());
}
}
Call<JsonObject> call = TagTasteApplicationInitializer.mRetroClient.callCustomFilterApI(type, queryMap, "1");
requestCall(call, listener);
}
source
share