I am using 2.0.0-beta-1 and when I try to call wit...
# ktor
j
I am using 2.0.0-beta-1 and when I try to call with:
Copy code
val response: HttpResponse = <http://client.post|client.post>(
    "<https://example.com/login>"
) {
    contentType(ContentType.Application.Json)
    LoginModel(username, password).also { body = it }
}
l get this error on the body part: This API is internal in Ktor and should not be used. It could be removed or changed without notice. I attached a screenshot just to make certain it is clear. Basically, how can I set the body? I also tried body = LoginModel(...) but same error, same result. If I add the annotation to allow an internal API it works on Android but fails to compile on iOS. I am using Kotlin Multiplatform, with Kotlin 1.6.10 and kotlinxSerialization = "1.3.2" This is how I initialized the httpclient.
Copy code
fun createHttpClient() = HttpClient {
    install(ContentNegotiation) {
        json(Json { isLenient = true; ignoreUnknownKeys = true; useAlternativeNames = false; prettyPrint = true }
        )
    }
    install(Logging) {
        logger = Logger.DEFAULT
        level = <http://LogLevel.INFO|LogLevel.INFO>
    }
}
I got past that error by using
Copy code
contentType(ContentType.Application.Json)
setBody(LoginModel(username, password))
Could someone fix the documentation at https://ktor.io/docs/request.html#objects please.
b
👍 1