# ktor

James Black

03/29/2022, 2:56 AM
I am using 2.0.0-beta-1 and when I try to call with:
Copy code
val response: HttpResponse = <|>(
) {
    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
setBody(LoginModel(username, password))
Could someone fix the documentation at please.


03/29/2022, 5:13 AM
👍 1