Hi. I tried ktor with xml support, but unfortunate...
# ktor
b
Hi. I tried ktor with xml support, but unfortunatelly i can not get it up. here is my sample i tried:
Copy code
@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.
Copy code
io.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class com.example.ktor.Modules
a
With what
Content-Type
the server replies to the client?
b
@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
You can find an answer here.
b
Thx @Aleksei Tirman [JB]