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”)
.feed(Data4)
.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] )
session
})
.exec(session =>session.set(“DigitalSign”, randomStringGenerator.getSignature(“C:\Working\private_key.pem”, “{\n\t"Name” : “${Name}”\n}")))

.exec(http(“CreateAccount”)
.post(“https://XXXXXXXXX.co.uk/v1/test”)
.body(StringBody("{\n\t"Name" : “${Name}”\n}"))
.header(“Authorization”, “Bearer XXXXXXXXXXXXXXX==”)
.header(“DigitalSignature”, “${DigitalSign}”)
.header(“X-Request-Id”, “${guid}”)
.header(“Content-Type”, “application/json”)
.check(status.is(200)))

setUp(scn1.inject(atOnceUsers(1))).protocols(httpProtocol)

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

Thanks in advance.

Regards,
Prash.

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: