CLOVIS
01/03/2023, 7:20 PMTRACE i.k.s.p.c.ContentNegotiation - Skipping because the type is ignored.
I'm using testApplication
with just the ContentNegotiation
plugin using KotlinX.Serialization
The test fails with 400 Bad Request with no provided body
, and Ktor seems to log that it decided to ignore the body for some reason?e5l
01/03/2023, 7:25 PMString
or ByteReadChannel
). If it's necessary, you can remove the type from ignored: https://api.ktor.io/ktor-server/ktor-server-plugins/ktor-server-content-negotiatio[…]egotiation/-content-negotiation-config/remove-ignored-type.htmlCLOVIS
01/03/2023, 7:27 PM@Serializable
class New(
val name: String,
)
CLOVIS
01/03/2023, 7:27 PMe5l
01/03/2023, 7:28 PMCLOVIS
01/03/2023, 7:29 PMCLOVIS
01/03/2023, 7:33 PMMETHOD: HttpMethod(value=POST)
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Authorization: Bearer fake:0
CONTENT HEADERS
-> Content-Length: 27
-> Content-Type: application/json
BODY Content-Type: application/json
BODY START
{"name":"A new department"}
BODY END
CLOVIS
01/03/2023, 7:33 PMe5l
01/03/2023, 7:35 PMCLOVIS
01/03/2023, 7:35 PMe5l
01/03/2023, 7:35 PMCLOVIS
01/03/2023, 7:36 PMe5l
01/03/2023, 7:36 PMCLOVIS
01/03/2023, 7:38 PMCLOVIS
01/03/2023, 7:38 PMCLOVIS
01/03/2023, 7:40 PMNew
class I shared aboveCLOVIS
01/03/2023, 7:42 PMTestApplication
configuration, but I have no idea what it could bee5l
01/03/2023, 7:43 PMTestApplication
is configured?CLOVIS
01/03/2023, 7:44 PMRouting
, ContentNegotiation
and Authentication
plugins (don't hesitate to ask for the specific config for each, this project is FOSS)
Specifically for ContentNegotiation:
val ApiJson = Json {
encodeDefaults = false
}
install(ContentNegotiation) {
json(ApiJson)
}
CLOVIS
01/03/2023, 7:45 PMe5l
01/03/2023, 7:45 PMCLOVIS
01/03/2023, 8:04 PMauthenticate {}
block, it worksCLOVIS
01/03/2023, 8:10 PMremote-server:test
, more precisely opensavvy.formulaide.remote.server.utils.ReproductionTest
• As it is, the test returns a 400 Bad Request with no body
• By disabling authentication (line 31), the test passesCLOVIS
01/03/2023, 8:13 PMCLOVIS
01/03/2023, 8:13 PM:
in:
-> Authorization: Bearer fake:0
CLOVIS
01/03/2023, 8:14 PM