Need help in passing data from one block of code to another in same class -- Please help

Hi ,

I’m new to Gatling and i started using gatling from the past one week.
Started writing the script for my app. Below is the code snippet.
I’m considering 1.user 2.signIn 3.rmIdfetch as 3 blocks
I want to capture the response data from user (first block) and want to use it as part of header in the signIn (Second block) – which i’m failing to do
Firstblock is executing successfully and able to capture the data into the variables. When i attempt to pass the captured data to the Second block it is failing.
Please help me in resolving the issue, i’m not sure what is wrong in my code.

**import** io.gatling.core.Predef._
**import** io.gatling.core.scenario.Simulation
**import** io.gatling.http.Predef._
**import** scala.concurrent.duration._
**class** Sample **extends** Simulation {

  **var** *randomNumber* = 1000
  **var** *randomUser* = <b>""
  </b>**val** *durationSeconds* = 1
  **var** *userNumber* = 0

  **val** *AddReview* = *scenario*(**"addrev"**)

    .exec(*flushHttpCache*)
    .exec(*http*(**"user"**)
      .post(**"https://accounts- users/"**)
      .headers(*Map*(**"offeringId"** -> **"App.apd.ito"**,
        **"Authorization"** -> **"App_IAM_Authentication app_appid=App.apd.ito,app_app_secret=xyz"**,
        *HttpHeaderNames*.*ContentType*->*HttpHeaderValues*.*ApplicationJson*,
        **"app_originatingip"** -> **"127.0.0.1"**))
      .body(*RawFileBody*(**"/Users/user1/Desktop/Gatling/gatling-charts-highcharts-bundle-2.1.7/user-files/simulations/computerdatabase/data/document.json"**)).asJSON
      .check(*jsonPath*(**"$.userId"**) .saveAs(**"usrid"**))
    .check(*jsonPath*(**"$.username"**).saveAs(**"p_username"**))
  )
  .exec(session => {
    *println*(session.get(**"p_username"**))
    *println*(session.get(**"usrid"**))
    session

  }

  )
    .pause(2)
    .exec(*http*(**"signIn"**)
      .post(**"https://accounts-e2e.platform.app.net/v1/iamtickets/sign_in/"**)
      .headers(*Map*(**"app_offeringId"** -> **"App.apd.ito"**,
        **"Authorization"** -> **"App_IAM_Authentication app_appid=App.apd.ito,app_app_secret=xyz"**,
        *HttpHeaderNames*.*ContentType*->*HttpHeaderValues*.*ApplicationJson*,
        **"app_originatingip"** -> **"127.0.0.1"**))
      .body(*StringBody*(**"""{"username" : "${p_username}","password" : "test123"}"""**)).asJSON
      .check(*jsonPath*(**"$.ticket"**).saveAs(**"p_token"**))
    )

    .pause(2)
    .exec(*http*(**"rmIdfetch"**)
      .post(**"https://accounts-e2e.platform.app.net/v1/users/me/rms"**)
      .headers(*Map*(**"app_offeringId"** -> **"App.apd.ito"**,
        **"Authorization"** -> **"App_IAM_Authentication app_appid=App.apd.ito,app_app_secret=xyz,app_token_type=IAM-Ticket,app_token=${p_token},app_userid=${usrid}"**,
        *HttpHeaderNames*.*ContentType*->*HttpHeaderValues*.*ApplicationJson*,
        **"app_originatingip"** -> **"127.0.0.1"**))
      .body(*RawFileBody*(**"/Users/user1/Desktop/Gatling/gatling-charts-highcharts-bundle-2.1.7/user-files/simulations/computerdatabase/data/Rm.json"**)).asJSON
      .check(*jsonPath*(**"$.rmId"**).saveAs(**"reamlm"**))
    )
    .exec(session => {
      *println*(session.get(**"reamlm"**))
      session
    }

    )

    .pause(2)

  setUp(

    *AddReview*.inject(rampUsers(1) over(1 seconds))

  )
}

Answer is here for the same post - http://stackoverflow.com/questions/34621451/using-gatling-to-loop-through-line-by-line-in-a-file-and-send-one-message-at-a-t

Thank you, found out that the issue was with endpoint URL. after fixing that it start working