I have a vendor built API that I am accessing that has spaces in some of the url parameters. For some reason on a few of the parameters, if it returns "+" it breaks the call. Is there anyway that I can change the encoding on Fuel to return %20 in the url parameter instead of "+" for a space? Thank you.
Example:
You can use an _interceptor_ (Request variant) as shown here. Here you would explicitly transform + to %20, if it's a GET request.
that worked perfectly, thank you!
For anyone stumbling on this with the same issue, here is the Interceptor that I used successfully.
kotlin
object GetRequestSpaceInterceptor : FoldableRequestInterceptor {
override fun invoke(next: RequestTransformer): RequestTransformer {
return { request ->
request.url = URL(request.url.toString().replace("+", "%20"))
next(request)
}
}
}
Most helpful comment
that worked perfectly, thank you!
For anyone stumbling on this with the same issue, here is the Interceptor that I used successfully.
kotlin object GetRequestSpaceInterceptor : FoldableRequestInterceptor { override fun invoke(next: RequestTransformer): RequestTransformer { return { request -> request.url = URL(request.url.toString().replace("+", "%20")) next(request) } } }