title: Gatling. Fetch data from response for next requests
body: <p>I need to fetch optional data from a JSON response to build next requests. I use <code>check(jsonPath("...rooms[0].id").exists.saveAs("...roomId"))</code> but if the user has no rooms, the result is interpreted by .check() as an error (e.g. <code>request count  4 (OK=3   KO=1)</code>)</p>
  
  <pre><code>object Users {
    val execute = exec(http("Users"))
      .get("/api/user?userIdentifier=${userId}")
      // if user has no rooms, the check results in an error (KO) 
      .check(jsonPath("$..user.rooms[0].id").exists.saveAs("roomId"))
      .pause(1)
  }
  
  object Room {
    val execute = exec(http("Room"))
      .get("/api/room?id=${roomId}")
      .pause(1)
  }
  
  val readOnlyScenario = scenario("Read only scenario") {
    .feed(userIdsdata)
    .exec(Users.execute,
      doIf(session =&gt; session.contains("roomId")) {
        Room.execute
      }
    )
  }
  </code></pre>
  
  <p>How can I fetch optional data from a JSON response and save it in the session (if present) without .check() failing when the data is not present?</p>