I'm trying to write unit tests for a post request but I'm having problems with the serialization:
Fail to serialize body. Content has type: class .models.NewWord, but OutgoingContent expected.
java.lang.IllegalStateException: Fail to serialize body. Content has type: class .models.NewWord, but OutgoingContent expected.
If you expect serialized body, please check that you have installed the corresponding plugin(like `ContentNegotiation`) and set `Content-Type` header.
My test according to the docs (2.0.0 btw) :
testApplication {
val c = createClient {
install(ContentNegotiation) {
json()
}
}
val r = c.post("/word") {
contentType(ContentType.Application.Json)
setBody(NewWord("a", "b", "c"))
}
}
I also tried header() instead of contentType() but doesn't work either
header(HttpHeaders.ContentType, ContentType.Application.Json.toString())
the NewWord class is Serializable ofc. what am I missing?