Is this KO expected behavior when 401 is returned even with check status?

I have the following piece of code

def create(payload: String):
ChainBuilder = exec(http(“Create”)
.post(EndPoint + “?_action=create”)
.check(, 403, 401).saveAs(“savedStatus”)))

Subsiquently in a feedeer i call the above as follows


.doIfEquals("${savedStatus}", 401) {


This however is resulting in an undesired KO when a 401 is returned from the server. I thoguht that the “.check(…,401)” will inhibit the KO? Is my understanding incorrect. If it is then is there a way to avoid registering a KO?


If you set an explicit check that allows 401 status, request won’t be KO on 401.
Make sure:
• you’re using the latest version: 3.6.1
• you’ve set your check on the correct request

Note: your code sample has create() while your create method takes a String body parameter. It’s impossible to properly help you unless you provide code that compiles properly.

So i did upgrade from 3.3.1 to 3.6.1 but still run into the same issue. Here is the http POST when create() is called.

HTTP request:
user-agent: Robot/Gatling
Authorization: Bearer abcdefgh
accept: application/json
content-type: application/json
content-length: 311
body:StringChunksRequestBody{contentType=‘application/json’, charset=UTF-8, content={
“userName” : “James”,
“givenName” : “Bond”,
“sn” : “Bond”,
“mail” : “”,
“telephoneNumber” : “444-444-4444”,
“password” : “xasdfasdfsdfsafdsf”

And sorry i missed the response which is 401 and as you can see is being checked as follows, yet i am still getting a KO which is equal to the number of concurrency.

.check(, 403, 401).saveAs(“savedStatus”)))

So will this considered a bug or am i still doing something wrong. To summarize the response HTTP code is “401” and i have “check(,401,403)” and yet a KO is counted towards the 401.

I’ve tried to reproduce, but to no avail. You can try the following and check for yourself:

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class StatusCheckWorkload extends Simulation {

  val httpProtocol = http
    .acceptEncodingHeader("gzip, deflate")

  val scn = scenario("scenario")
    .check(, 404)))


It’s very likely that the error is on your side.

Please comply to this group’s terms:

  • Provide a Short, Self Contained, Correct (Compilable), Example (see

Yes indeed it was my own doing. I was just looking at the KO without paying attention to the actual reason which is another “check” in my sequence of steps which was failing and hence contributing to the KO. Sorry for the false alarm.