Jackson Cleary
09/04/2022, 2:59 AMsuspend fun getUpcomingLaunches(): List<Launch> =
client.get {
url {
protocol = URLProtocol.HTTPS
host = "<http://api.spacexdata.com/v4|api.spacexdata.com/v4>"
encodedPath = "launches/upcoming"
}
}.body()
This works fine on Android, however on iOS it is failing with 404 not found. From the logs it looks like the correct url is being built (https://api.spacexdata.com/v4/launches/upcoming) although obviously it is not calling that url exactly. However, f I change the code though to
suspend fun getUpcomingLaunches(): List<Launch> =
client.get("<https://api.spacexdata.com/v4/launches/upcoming>").body()
it works as expected.
I’m guessing it is a bug in Darwin engine, but just wanted to check I’m not doing something stupid or if it’s a known issue. TIA!Jackson Cleary
09/04/2022, 3:14 AMsuspend fun getUpcomingLaunches(): List<Launch> =
client.get {
url {
protocol = URLProtocol.HTTPS
host = "<http://api.spacexdata.com|api.spacexdata.com>"
encodedPath = "v4/launches/upcoming"
}
}.body()
(ie. moving v4
from host
to encodePath
) fixes the issue. Strange that the behaviour is different for the different engines but 🤷♂️Jackson Cleary
09/04/2022, 3:21 AMAleksei Tirman [JB]
09/05/2022, 7:45 AMJackson Cleary
09/06/2022, 11:14 PM