I have a retrofit request
@GET("{link}")
suspend fun getFilePart(@Path(value = "link") link: String): Deferred<NetworkResponse<ResponseBody, NetworkError>>
and when i call it i pass a 'link'
val base = if (BuildConfig.DEBUG) BuildConfig.TRANSFER_URL_DEBUG else BuildConfig.TRANSFER_URL
apiManager.appApiService(base).getFilePart(it.link)
Lets say the link is something like "https://storage_dev.example.com/10002/6d197e1e57e37070760c4ae28bf1..." but in the Logcat i see that some characters get urlEncoded. For example
the following Url https://storage_dev.example.com/10002/6d197e1e57e37070760c4ae28bf18d813abd35a372b6a1f462e4cef21e505860.1&Somethingelse
As i can see the link is a String that has many characters inside that get encoded like "&" has turned to "?"
How can i prevent this?
CodePudding user response:
You can add encoded = true
to your request param to tell retrofit to not encode it again:
/**
* Specifies whether the parameter {@linkplain #value() name} and value are already URL encoded.
*/
boolean encoded() default false;
Example:
@Path(value = "link", encoded = true)
CodePudding user response:
If your link includes the baseurl part you should use @Url to avoid that problem
@GET
suspend fun getFilePart(@Url link: String): Deferred<NetworkResponse<ResponseBody, NetworkError>>