Login using OTP

Hi All,

I am totally new to Gatling and Scala, and I am not able to save those responses one by one and use it for other requests.

Below are the steps that I want to perform.

  1. First step is to do a Get Request of a URL which provides a random no and public key under its response body, I have to save these values so that I can parse them to next step.
    {ds3: true, twoFA: true,…}
    ds3:true
    publicKey:“DEEC326B84B4CE83BAC3849C906797ED92A9AE99A440C2E0C‌​E0FA3E7811C3225BD285‌​65AAF70EFB2E33C3154E‌​E8793278942CF41FDE1E‌​5FE2F25BCA9203B70CA0‌​F55095A16FB26B79F00B‌​D0CCE138F617C1C6A37C‌​C78804F0F1A260FBAD62‌​D1B1CBCD8F275A56CB6A‌​5DC0B9C563601D32E73C‌​E508059995BC30C6A200‌​A5A1100AD791FA8C47CA‌​A55EF07FE272256B5A7C‌​12590C5D25DFFD1C12E0‌​A0B15B8C24E96F5FD295‌​BA970D0D8739EADC0BD0‌​FFCA64AD2781C6650187‌​54C160998C8AF4FE625E‌​C2CC406A14FAF52FB4FC‌​6EF8A4C8146C38204241‌​8BD851CAE394BA20E201‌​D1BEDD” random:“91B8BAF5A6643FBA61F4990E23C47007”
    twoFA:true

I have to save this into a variable over a session

  1. Next step is do a post request for entering User-id and password, password gets encrypted.

Under Request Payload:

  1. {userid: “xxxx”,…}
  2. password:“2400ff0bb517132b229f290bde152c99d27e713f7da6de551f77c553c76f3eba306e5ccb65777a4ad708f09017edb1de3e740fd823fd4acfc6cdc62a8bb562a19ecf935bf63138c5ab71f2160dc48acf0acaae18aac31d6b2402c11f043504684ec1f28d0a2651be6f8054e00bbc630bd9c53eccb6ce3dcc05d0c98ba9ad8d8510b6bb8070a519438f1355f5b8da3cd1bd2eaef52d2aea4db003ad8775bdb291a9948d3d9d91ead2da5453f3eb825fce3f923d37c6cfeec009ce988551c2d21a1c65d65b80bba421617871d6b9546ab0849e54361aeaee710f9432e57092f6ffa1c09a70a4d3a10fc0ee75ac726b3a8a4c67d892c68b1190efee9b8a78ea97a3”
  3. random:“51F5A2F0938004955128FA7AC764583E”
  4. userid:"xxxx"1.

Under Response body :
{"$type":“Ds3Result”,“success”:true,“errorCode”:[],“message”:[]}

  1. Also I have to save XSRF token from the cookie to maintain the session.
  2. Then there is another POST request for O.T.P authentication, which I have to fetch from Rest API.

Can someone help me on this to achieve above mentioned scenario.