# How to pass the variable defined in scala to the JSON file using ElFileBody command

**URL:** <https://community.gatling.io/t/how-to-pass-the-variable-defined-in-scala-to-the-json-file-using-elfilebody-command/6522>\
**Category:** Gatling (Open-Source)\
**Created:** [March 1, 2022, 4:19pm UTC](https://community.gatling.io/t/how-to-pass-the-variable-defined-in-scala-to-the-json-file-using-elfilebody-command/6522 "2022-03-01T16:19:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chittuvtu](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Chittuvtu](https://community.gatling.io/u/Chittuvtu)\
**Post date:** [March 1, 2022, 4:19pm UTC](https://community.gatling.io/t/how-to-pass-the-variable-defined-in-scala-to-the-json-file-using-elfilebody-command/6522/1 "2022-03-01T16:19:15Z")

</div>

Hi,

We are defining the variable using def at global level and trying to pass this value as parameter in the json using ElFileBody command, but its not working.

def parameter=

Inside exec used the below command

.body(ElFileBody(“ProjectName/0002\_request.json”))

in the above request, replaced the json content with ${parameter}.

While executing am getting error as parameter variable not found

Please help on this issue.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 1, 2022, 4:48pm UTC](https://community.gatling.io/t/how-to-pass-the-variable-defined-in-scala-to-the-json-file-using-elfilebody-command/6522/2 "2022-03-01T16:48:16Z")

</div>

This is not how Gatling Expression Language works.  
It replaces placeholders with matching Session attribute’s value.  
It can’t be used to call a method.

What you can do if first is to push a new Session attribute:

```java
.exec(session -> session.set("parameter", parameter))

```

---

<div class="post-metadata">

**Author:** ![Chittuvtu](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Chittuvtu](https://community.gatling.io/u/Chittuvtu)\
**Post date:** [March 2, 2022, 5:40am UTC](https://community.gatling.io/t/how-to-pass-the-variable-defined-in-scala-to-the-json-file-using-elfilebody-command/6522/3 "2022-03-02T05:40:27Z")

</div>

Thanks for your reply.
