Open leandrofrs opened 4 months ago
@leandrofrs yes karate does not give you the status text and interestingly for the last 7 years no one has needed it :)
for contributor reference, I think the line to look at is this: https://github.com/karatelabs/karate/blob/master/karate-core/src/main/java/com/intuit/karate/http/ApacheHttpClient.java#L309
and it seems you can call httpResponse.getStatusLine().getReasonPhrase()
.
in the meantime, I was seeing if you can fallback to curl using this approach: https://stackoverflow.com/a/64352676/143475 - I tried to do some digging if curl can get you the status message, but gave up.
you always have the option of writing some java code that fires up an apache http client and using it via java interop. personally I think these tests for a 400 are not worth it, but if really important - this java interop option is what I would recommend
The current implementation of karate only returns the status as an int by implementing the method getStatusCode(), as described in the following documentation:
https://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/util/HTTPRequestBuilder.Response.html
Is there any way to return the status message (by implementing the method getStatusText() to Karate) that comes with the status code? Like 400 = Bad Request, 200 = OK
The given problem is that I've an API that has different status messages for the code 400. I want to differentiate my test cases based on the message that comes with the code.