How to escape session variable processing?

I have a request that is like the following…

`

val bodyJson = “”"{“id”:“001”, “heading”:“Dear ${first_name}”}"""

val httpRequest = http(“Some Request”)
.post("/someservice")
.header(“Authorization”, “${access_token}”)
.body(StringBody(bodyJson))
.asJSON

`

I need “Dear ${first_name}” to be literal. How do I escape the text “${first_name}” so that it will not get processed as a session variable? I’ve tried various means of escaping special chars, but nothing’s working. My current work around is to set the following before executing the request, but that seems extremely janky AND adds an extra step to all of my chains.

`
.exec(session => session.set(“first_name”, “${first_name}”))

`

Thanks,
Christian

We don’t currently have such escaping, sorry: you’re the first one to ever ask.
Do you feel like contributing?

I’m new to Scala and Gatling. I guess I could try. Where do I start?

Here’s the compiler: https://github.com/gatling/gatling/blob/master/gatling-core/src/main/scala/io/gatling/core/session/el/ElCompiler.scala
And here’s the spec where to add tests: https://github.com/gatling/gatling/blob/master/gatling-core/src/test/scala/io/gatling/core/session/el/ElSpec.scala

This is non trivial: you have to be familiar with parsers, and then learn Scala Parser Combinators.

Good luck :slight_smile: