# How to supply parameter values to contents of a JSON file

**URL:** <https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015>\
**Category:** Gatling (Open-Source)\
**Created:** [June 9, 2023, 11:34am UTC](https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015 "2023-06-09T11:34:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GIGATeun](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@GIGATeun](https://community.gatling.io/u/GIGATeun)\
**Post date:** [June 9, 2023, 11:34am UTC](https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015/1 "2023-06-09T11:34:21Z")

</div>

Say I have a JSON request body file `query.json` with the following contents:

```auto
{
  "user_id": "#{userId}",
  "query": "SELECT * FROM example;"
}

```

I am using the body in a `scenario` like this:

```auto
  private final ScenarioBuilder scenario =
    scenario("Load test")
      .exec(
        http("Query")
          .post("<API>")
          .headers(ImmutableMap.of("content-type", "application/json"))
          .body(RawFileBody("bodies/query.json")));

```

I now wish to use Gatling functionality to supply the user ID but keep the query constant. How should I do that? I have looked into [Gatling EL](https://gatling.io/docs/gatling/reference/current/core/session/el/) and I am aware that _“Only Gatling DSL methods will interpolate Gatling EL Strings. You can’t use Gatling EL in your own methods or functions.”_. I was unable to extract a working example from the docs, hence my question here.

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [June 9, 2023, 11:50am UTC](https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015/2 "2023-06-09T11:50:44Z")

</div>

Hi @GIGATeun,

Do you know about [`ElFileBody`](https://gatling.io/docs/gatling/reference/current/http/request/#elfilebody) (to put instead your `RawFileBody`)

Hope it helps.

Cheers!

---

<div class="post-metadata">

**Author:** ![GIGATeun](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@GIGATeun](https://community.gatling.io/u/GIGATeun)\
**Post date:** [June 9, 2023, 2:45pm UTC](https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015/3 "2023-06-09T14:45:20Z")

</div>

Yes, ElFileBody appears to be exactly what I need. However, I am not sure on how to use it. How do we set our parameter userId?

---

<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:** [June 9, 2023, 3:09pm UTC](https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015/4 "2023-06-09T15:09:08Z")

</div>

Please check our free online courses: [https://academy.gatling.io/](https://academy.gatling.io/)

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [July 9, 2023, 3:09pm UTC](https://community.gatling.io/t/how-to-supply-parameter-values-to-contents-of-a-json-file/8015/5 "2023-07-09T15:09:14Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
