How to put variable in http body

I save necessary information in "identity_id_B" and need to send it in the next request body.
How can i save this info in variable?
Thanks in advance



 .exec(http("Create id user B")
 .post(URL)
 .body(StringBody(session => "...")).asJSON
 
 .check(jsonPath("$.identityId")
 .saveAs("identity_id_B"))
  )

 exec(http("Send invite")
  .post(OTHER_URL)
  .headers(sentHeaders_A)
  .body(StringBody(session => "{\"invitee\":\"" + identity_id_B!! + "\",\"message\":\user B\"}")).asJSON
   )
}

What you are looking for is session variables and expressions…

.body( StringBody( “”"{“invitee”:"${identity_id_B}",“message”:“user B”}""" ) )

Unfottunately, in this case :.body( StringBody( “”"{“invitee”:"${identity_id_B}",“message”:“user B”}""" ) )
i have REQUEST BODY: null

in this one: .body(StringBody( session => {"“invitee”:"${identity_id_B}",“message”:“user B”"})).asJSON
REQUEST BODY: “invitee”:"${identity_id_B}",“message”:"user B"

maybe i need to create some session variable?

The first request is supposed to be creating the session variable. But you are missing a leading dot on your second exec, which means it is not being chained properly. Add the missing “.” and try again.

.repeat(NUMBER_OF_LOOPS_FOR_GET) {
exec(http("Send invite")
 .post(CONTEXT_URL")
 .headers(sentHeaders_A)
 .body(StringBody( session => {"\"invitee\":\"${identity_id_B}\",\"message\":\"user B\""})).asJSON
 .check(status.is(200))
)}

Its ok in scenario, i missed dot in example(
everything work correctly, but i cant to transfer the value to a variable
I think that its necessary to create a session variable
All i need is to put my saved previously value into body.
But I dont know how

Re-read my first reply.