I'm using retrofit 2 and when I want to call a url like base/first/second slashes are converted into %2F According to retrofit official document I should be able to use
(@Path(value = "address" , encode = false)
but Android studio says : cannot find symbol method encode()
Try -
encoded=false
. Not encode=false
Yes I had this problem from retrofit and I solved it with that:
Shortly, your answer is: (@Path(value ="address", encode = false) String address)
For example our link is: https://mobile.test/android
Firts off all, your Builder want to have an setEndpoint(). You can give "http:/" or "https:/" .
RestAdapter.Builder restBuilder = new RestAdapter.Builder()
.setEndpoint("https://")
.setConverter(new GsonConverter(gson))
.setClient(new OkClient(new OkHttpClient()));
return restBuilder.build();
Secondly, you should give your String value to @GET("/{address}"):
@GET("/{address}") void getExampleModels(@Path(value = "address", encode = false) String address, Callback<exampleModel> callback);
Finally, you can call it with String parameter without your error:
getYourClass().getExampleModels(
"mobile.test/android",
newCallback<exampleModel>(){
. . .
});
Have a nice day.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With