Giorgi
05/13/2024, 1:45 PMGiorgi
05/13/2024, 1:48 PMprivate val client = HttpClient {
install(ContentNegotiation) {
Json {
ignoreUnknownKeys = true
isLenient = true
}
}
}
request
client.get("<https://owapi.eu/stats/pc/shalva-21962/complete>").body<PlayerProfileStatsDTO>()
It fails with
Expected response body of the type 'class io.github.shalva97.overwatch_player_search_api.models.profile.PlayerProfileStatsDTO (Kotlin reflection is not available)' but was 'class io.ktor.utils.io.ByteBufferChannel (Kotlin reflection is not available)'
In response from `<https://owapi.eu/stats/pc/shalva-21962/complete>`
Response status `200 `
Response header `ContentType: application/json; charset=UTF-8`
Request header `Accept: */*`
As you can see it has ContentType: application/json;
so it should just work, right?Giorgi
05/13/2024, 1:49 PM@Serializable
public data class PlayerProfileStatsDTO(
val icon: String,
val name: String,
val endorsement: Int,
val endorsementIcon: String,
val title: String,
// val ratings: List<RatingDTO>,
val gamesWon: Int,
val gamesLost: Int,
val private: Boolean
)
hfhbd
05/13/2024, 2:06 PMinstall(ContentNegotiation) {
json(
Json {
},
)
}
Giorgi
05/13/2024, 2:10 PMGiorgi
05/13/2024, 2:10 PM