hruan
05/04/2022, 9:53 AM415 when 201 is expected. Running the app and calling the same endpoint via curl works as expected, leading me to believe that I’ve done something wrong with the test client setup. Any pointers would be appreciated. Details in thread.hruan
05/04/2022, 9:54 AMtestApplication {
// ... test application setup ...
val testClient = createClient {
install(ContentNegotiation) {
json(Json { DefaultJson })
}
install(Auth) {
bearer {
loadTokens {
BearerTokens(jwt, "nope")
}
}
}
}
<http://testClient.post|testClient.post>("/some-post-endpoint") {
accept(ContentType.Application.Json)
contentType(ContentType.Application.Json)
setBody(CreationRequest("test", listOf("test"), "testOrg", "testId"))
}.apply {
assertEquals(HttpStatusCode.Created, status)
}
}
ContentNegotiation plugin config match the server.hruan
05/04/2022, 10:27 AMcreateClient bit and doing the post manually
<http://client.post|client.post>("/some-post-endpoint") {
accept(ContentType.Application.Json)
contentType(ContentType.Application.Json)
header(HttpHeaders.Authorization, "Bearer $jwt")
setBody(
"""
{
... some raw json ...
}
""".trimIndent()
)
}.apply {
assertEquals(HttpStatusCode.Created, status)
}
Still returns 415 Unsupported Media Type . What am I missing here?hruan
05/04/2022, 10:45 AMtestApplication 🤦