Got a ktor client POST request that does not neces...
# ktor
s
Got a ktor client POST request that does not necessarily return anything back, so I can’t check if it went right by trying to deserialize the response, as I am doing in a previous thread here. Is there that I can simply assert that the post request successfully went through? Or is my best bet to simply do a check for
response.status == HttpStatusCode.OK
?
a
A statuscode should indicate if a response was good
s
Yeah figured as much. I was relying on the exception being thrown in all other cases so this would just be a bit different which is why I was wondering if there was any
response.assertSuccessful()
. But the status check is simple enough, thanks for reassuring me 😊
a
Please note that this is the convention and the standard. A lot of API's don't adhere to this standard. And GraphQL defines 200 as a succesful graphQL response, even though the response itself can contain an
errors
block.
s
Yeap, luckily this time I am certain I am not communicating with a GraphQL backend. The backend code for that endpoint is literally just a function returning nothing in a Spring backend context in a class annotated with
@RestController
Copy code
@PostMapping("/{id}/foo")
fun someFunction(@PathVariable id: UUID): Unit {
    someService.sideEffect(id)
}
I would not expect this to return 200 if anything goes bad