Hello, I’m trying to set contentType in `defaultRe...
# ktor
a
Hello, I’m trying to set contentType in
defaultRequest
but it crashesh in iOS, and when I wanna set
contentType
in post request, this exception raise
Copy code
I have also installed `ContentNegotation` and `json`
Copy code
Fail to serialize body. Content has type: class org.metatude.paxfa.auth.login.LoginEmailRequestDto, but OutgoingContent expected.
If you expect serialized body, please check that you have installed the corresponding plugin(like `ContentNegotiation`) and set `Content-Type` header.
a
Could you please share a code snippet to reproduce your problem?
a
I just configure the
HttpClient
with bellow configure, and it cause a crash on iOS.
Copy code
defaultRequest {
    url {
        protocol = URLProtocol.HTTPS
        host = baseUrl
    }
    contentType(ContentType.Application.Json)
   
}
 install(ContentNegotiation) {
        json()
    }
it is works on
1.6.7
but crash in
2.0.0-beta1
ps: when you wanna send post request with data class (I also make it serialize using
@Serializable
it causes crash).
a
I cannot reproduce it with an EAP version of Ktor, like
2.0.0-eap-327
. Please try to use that version with the new native memory model enabled (
kotlin.native.binary.memoryModel=experimental
in Gradle). Also, include the following repositories in the Gradle build:
Copy code
maven { url "<https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven>" }
maven { url "<https://maven.pkg.jetbrains.space/public/p/ktor/eap>" }