Parameter value not getting replaced

Hi All,

Parameter value for Name is not being replaced in the below script

val httpProtocol = http // 4

val scn1 = scenario(“Login”)
.exec(session =>session.set(“guid”, randomUUID().toString))
.exec(session =>session.set(“myString”, “{\n\t"Name” : “${Name}”\n}"))
.exec(session => {
println( “myString is :” + session(“myString”).as[String] )
.exec(session =>session.set(“DigitalSign”, randomStringGenerator.getSignature(“C:\Working\private_key.pem”, “{\n\t"Name” : “${Name}”\n}")))

.body(StringBody("{\n\t"Name" : “${Name}”\n}"))
.header(“Authorization”, “Bearer XXXXXXXXXXXXXXX==”)
.header(“DigitalSignature”, “${DigitalSign}”)
.header(“X-Request-Id”, “${guid}”)
.header(“Content-Type”, “application/json”)


Is there a way i can execute a custom function with parameters, as shown above?

Thanks in advance.


you can’t use gatling expression language in a session function -

so in your session.set calls instead of ${Name}, you need session(“Name”).as[String]

Thanks for the reply James.

I wanted to read the value of Name as a parameter which comes from my feeder.

Tried as below but not having any luck.

val body = “{\n\t"Name” : “${Name}”\n}"

Hi All,

Badly stuck on this.

the ${Name} param is being replaced by the value given in feeder, in the below line.

.header(“XXXXXXXX”, “${Name}”)

But the same is not happening in the below line.

.header(“DigitalSignature”, randomStringGenerator.getSignature(“C:\Working\private_key.pem”, “{\n\t"Name” : “${Name}”\n}"))

what am i doing wrong?

Thanks in advance for your help.

Sorted !!!

Should have paid attention to James :slight_smile: