I can't seem to use Session Variables stored from a request in a subsequent Request

The code:

package simulations

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

class StarWarsBasicExample extends Simulation

// 1 Http Conf
val httpConf = http.baseUrl(“https://swapi.dev/api/films/”)

// 2 Scenario Definition
val scn = scenario(“Star Wars API”)
.exec(http(“Get Number”)
.exec(session => {
val movie = session(“episodeId”).as[String]


// 3 Load Scenario


Trying to grab a variable from the first Get request, and inject that variable into a second request, but unable to do so despite using the documentation. There might be something I’m not understanding.

When I use breakpoints, and navigate through the process, it appears the session execution happens AFTER both of the other requests have been completed (by which time is too late). Can’t seem to make that session execution happen between the two requests.

.get("$episode")) is not correct Gatling EL syntax. It should be .get("${episode}"))