James Black
03/29/2022, 2:56 AMval 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.
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>
}
}
contentType(ContentType.Application.Json)
setBody(LoginModel(username, password))
Could someone fix the documentation at https://ktor.io/docs/request.html#objects please.benkuly
03/29/2022, 5:13 AM