Hi. Im trying to parse JSON but throws NoTransform...
# ktor
g
Hi. Im trying to parse JSON but throws NoTransformationFoundException.
So here is my client setup
Copy code
private val client = HttpClient {
        install(ContentNegotiation) {
            Json {
                ignoreUnknownKeys = true
                isLenient = true
            }
        }
    }
request
Copy code
client.get("<https://owapi.eu/stats/pc/shalva-21962/complete>").body<PlayerProfileStatsDTO>()
It fails with
Copy code
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?
and this is the model class
Copy code
@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
)
h
You have to call json:
Copy code
install(ContentNegotiation) {
  json(
    Json {
              
    },
  )
}
📌 1
g
ahh well, thats some dumb mistake I made
thanks for reply
124 Views