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
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?