The following code `GET` does not allow me to prop...
# ktor
j
The following code
GET
does not allow me to properly override the base URL set for my
HttpClient
. The
route.path
returns a fully qualified url ie *https://movies-test.com/sp-json/v1/movies* But this doesn’t override the URL merging strategy of
HttpClient.defaultRequest
My resolved URL looks like so: _*https://movies-test.com/sp-json/v1/https://movies-test.com/sp-json/v1/movies*_
Copy code
client.get {

    url {
        path(route.path)
        if (components.isNotEmpty()) {
            appendPathSegments(components = components)
        }
    }
    requestBody?.let(::setBody)
}
Here is how I setup my
HttpClient
Copy code
defaultRequest {
    url {
        url.takeFrom(baseUrl)
        parameters.appendIfNameAndValueAbsent("output", "json")
    }

    headers.appendIfNameAbsent(
        name = HttpHeaders.ContentType,
        value = ContentType.Application.Json.toString()
    )
    headers.appendIfNameAbsent("token", apiToken)
}
c
you only add the
path
. you need to replace the
url
with
route.path
client.get(route.path)
a
What is your
baseUrl
look like?
j
I was able to get the baseURL replacement working by passing the URL into
get(...)
instead of using
path(…)