How to get response body element from the given request in Gatling? What wrong in the code??

Hi,
The last line I am unable to get the Deal ID in order to pass the deal ID to the next request & it is failing with the error What wrong the code is?

My requirement is, from the response body of the “CreateDealAPI” highted below, I want to fetch “DealID”

.exec(http(“CreateDeal”)
.options(uri2 + “/deal/CreateDeal/”)
.header(“cookie”, “${value}”)
.headers(headers_30)
.resources(http(“GA”)
.post(uri4 + “/j/collect?v=1&_v=j91&a=900484513&t=event&_s=5&dl=https%3A%2F%2Fmpc-ui-rdl.ext.hp.com%2Fsmps%2Fdeal&dp=%2Fdeal&ul=en-us&de=UTF-8&dt=Deal&sd=24-bit&sr=1536x864&vp=1536x450&je=0&ea=CreateDeal&ev=993&_u=SACAAEABEAAAAC~&jid=809919146&gjid=646711591&cid=1900231125.1579843281&tid=UA-145853566-1&_gid=1743349099.1626078978&_r=1&z=1180422588”)
.header(“cookie”, “${value}”),
//.headers(headers_3),
http(“GA”)
.post(uri4 + “/j/collect?v=1&_v=j91&a=900484513&t=event&_s=5&dl=https%3A%2F%2Fmpc-ui-rdl.ext.hp.com%2Fsmps%2Fdeal&dp=%2Fdeal&ul=en-us&de=UTF-8&dt=Deal&sd=24-bit&sr=1536x864&vp=1536x450&je=0&ea=CreateDeal&ev=993&_u=SACAAEABEAAAAC~&jid=809919146&gjid=646711591&cid=1900231125.1579843281&tid=UA-145853566-1&_gid=1743349099.1626078978&_r=1&z=1180422588”)
.header(“cookie”, “${value}”),
//.headers(headers_4),
http(“CreateDeal”)
.post(uri2 + “/deal/CreateDeal/”)
.headers(headers_33)
.header(“cookie”, “${value}”)
.body(RawFileBody("./src/test/resources/sMPS/smpsperformance/0031_request.json")).asJson
.check(jsonPath("$.dealId").saveAs(“dealID”))))

Receiving this error while running -

type mismatch;
found : io.gatling.core.check.CheckBuilder[io.gatling.core.check.jsonpath.JsonPathCheckType,com.fasterxml.jackson.databind.JsonNode,String]
required: io.gatling.http.check.HttpCheck
.check(jsonPath("$.dealId").saveAs(“dealID”))))

This is a compile error.

The code you provided compiles just fine as long as you don’t remove the following imports:

import io.gatling.core.Predef._
import io.gatling.http.Predef._

Note:

RawFileBody("./src/test/resources/sMPS/smpsperformance/0031_request.json") is wrong.

RawFileBody(“sMPS/smpsperformance/0031_request.json”) is correct