https://kotlinlang.org logo
Title
b

bodo

04/01/2023, 2:57 PM
Hi. I tried ktor with xml support, but unfortunatelly i can not get it up. here is my sample i tried:
@Serializable
@SerialName("modules")
data class Modules(
    val resId: String?,
    val contentUrl: String?,
)

val httpClient = HttpClient(Android) {
    install(ContentNegotiation) {
        xml()
    }
}

lifecycleScope.launch {
    val modules = httpClient.get("...").body<Modules>()
    Log.d("MODULES", modules.toString())
}
But when i do the
httpClient.get(url).body<Modules>()
i get the following error. can you please tell me what i am doing wrong.
io.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class com.example.ktor.Modules
a

Aleksei Tirman [JB]

04/03/2023, 9:21 AM
With what
Content-Type
the server replies to the client?
b

bodo

04/03/2023, 6:34 PM
@Aleksei Tirman [JB] Thx for the hint with the Content-Type. The default one is
Application/Xml
. But the server returns
Text/Xml
. But now i get an error because i did not define every property in my data model. Is there a possibility to ignore unknown properties?
a

Aleksei Tirman [JB]

04/04/2023, 4:28 AM
You can find an answer here.
b

bodo

04/06/2023, 8:00 AM
Thx @Aleksei Tirman [JB]