Capture JSON Response and pass to another Request

Hi,

I am able to capture the JSON Response from the previous Request but not able to pass the particular value in next Request. Here is the example-

http(“request_100”)
.post(“/cometd/handshake”)
.headers(headers_100)
.body(StringBody(“”“[{“id”:“1”,“version”:“1.0”,“minimumVersion”:“1.0”,“channel”:”/meta/handshake",“supportedConnectionTypes”:[“long-polling”,“callback-polling”],“advice”:{“timeout”:60000,“interval”:0}}]“”“)).asJson
.check(jsonPath(”$…clientId").find.saveAs(“client1”)),

http(“request_101”)
.post(“/cometd/connect”)
.headers(headers_100)
.body(StringBody(“”“[{“id”:“2”,“channel”:”/meta/connect",“connectionType”:“long-polling”,“advice”:{“timeout”:0},“clientId”:“${client1}”}]“”“)).asJson
.check(jsonPath(”$…*").find.saveAs(“resp1”)),

.exec ( session => {
println(session(“client1”).as[String])
println(session(“resp1”).as[String])
session
})

The Response from request_100 is -

[{“minimumVersion”:“1.0”,“clientId”:“f1rm2vubs7q4h61iot8ghn6ai9u”,“supportedConnectionTypes”:[“long-polling”],“channel”:“/meta/handshake”,“id”:“1”,“version”:“1.0”,“successful”:true}]

clientId is captured from the previous request but while passing the clientId using client1, I am seeing the below error to build the request_101. Here is the error-

---- Errors --------------------------------------------------------------------

request_101: Failed to build request: No attribute named ‘clie 1 (11.11%)
nt1’ is defined

17:03:31.917 [ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - ‘hook-29’ crashed with ‘j.u.NoSuchElementException: No attribute named ‘resp1’ is defined’, forwarding to the next one

It looks like those requests are wrapped in a resources group, meaning they are executed in parallel, not sequentially, so there’s no way request_101 can be built based on request_100’s result. You must execute them sequentially in sequential distinct exec blocks.