Zane W
01/16/2024, 9:42 AM.sse()
function in Ktor 3.0 beta 1, and I get
io.ktor.sse.SSEException: io.ktor.sse.SSEException: Expected status code 200 but was: 400 at io.ktor.client.plugins.sse.BuildersKt$serverSentEventsSession$2.invokeSuspend(builders.kt:56) at _COROUTINE.BOUNDARY.(CoroutineDebugging.kt:46) at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230) at kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl(Errors.kt:156) at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(Errors.kt:114)
my request body works in other clients.
When I get this error, I don't know the response body, and I can't access the response header. It just failed without any way to know why. btw, I also set the expectSuccess = false
in the client, but it does not work apparently.Zane W
01/16/2024, 12:28 PMsetBody
, the requestBody variable is a json string:
.sse(url, request = {
method = HttpMethod.Post
headers {
append(HttpHeaders.Accept, ContentType.Text.EventStream)
append(HttpHeaders.ContentType, ContentType.Application.Json)
}
setBody(requestBody)
}) {...}
all other fields are set allright.Zane W
01/16/2024, 1:31 PMAleksei Tirman [JB]
01/17/2024, 11:57 AM