How to use both feeder and value from session in Gatling

Im trying to create a payload having both feeder and session values, but it fails to read feeder value.
Any solution to this?

scenario(“check”)
.feed(ids)
.exec(http(“check”)
.post("/check")
.header(“X-Token”, session => session(“token”).as[String])
.body(StringBody(session =>
s"""
|{
| “id”: “${id}”,
| “subId”: “${subId}”
| “addressId”: “”"" + session(“token”).as[String] + “”""
|}
“”".stripMargin
))

IMO, the feeder set the variables directly in session.

With your example:

val token = “…”

val scn = scenario(“check”)

.feed(ids)
.exec(session => session.set(“token”, token))
.exec(http(“check”)
.post("/check")
.header(“X-Token”, “${token}”)
.body(StringBody(
“”"
|{
| “id”: “${id}”,
| “subId”: “${subId}”
| “addressId”: ${token.jsonStringify()}
|}
“”".stripMargin
))

Assuming that id and subId are coming from the feeder and token is a value.
Note:

  1. I put token in session
  2. I used EL String everywhere (no “s” before the string)

Hey Thanks, the confusion is cleared now