# Unable to post request body

**URL:** <https://community.gatling.io/t/unable-to-post-request-body/3202>\
**Category:** Gatling (Open-Source)\
**Created:** [August 19, 2016, 11:35am UTC](https://community.gatling.io/t/unable-to-post-request-body/3202 "2016-08-19T11:35:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anuja\_Kadloor](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Anuja\_Kadloor](https://community.gatling.io/u/Anuja_Kadloor)\
**Post date:** [August 19, 2016, 11:35am UTC](https://community.gatling.io/t/unable-to-post-request-body/3202/1 "2016-08-19T11:35:29Z")

</div>

Hi Stephanie,

I’m trying to post a request along with JSON body using gatling. However, the body is not getting attached with request.  
I know this for sure because expected response with request body and without it is different.  
Here is my code:-

```auto
class RecordedSimulation extends Simulation {

 val httpProtocol = http
  .baseURL(url)
  .inferHtmlResources()

 val headers_0 = Map("Origin" -> "chrome-extension://aejoelaoggembcahagimdiliamlcdmfm")

    val uri1 = "abc.com"

 val scn = scenario("RecordedSimulation")
  .exec(http("request_0")
   .post("/abc/efg")
   .headers(headers_0)
   .body(RawFileBody("RecordedSimulation_0000_request.txt"))
   .basicAuth("uid","pwd")
   .check(bodyString.is(RawFileBody("RecordedSimulation_0000_response.txt"))))

 setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Anuja\_Kadloor](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Anuja\_Kadloor](https://community.gatling.io/u/Anuja_Kadloor)\
**Post date:** [August 22, 2016, 2:29pm UTC](https://community.gatling.io/t/unable-to-post-request-body/3202/2 "2016-08-22T14:29:39Z")

</div>

Hi All,

Any help would be highly appreciated.

Thanks,  
Anuja

---

<div class="post-metadata">

**Author:** ![Vrushalee\_Ajotikar](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@Vrushalee\_Ajotikar](https://community.gatling.io/u/Vrushalee_Ajotikar)\
**Post date:** [August 23, 2016, 11:31am UTC](https://community.gatling.io/t/unable-to-post-request-body/3202/3 "2016-08-23T11:31:35Z")

</div>

Hi Anuja,

You have used bodyString.is(RawFileBody(“RecordedSimulation\_0000\_response.txt”). I had the same case and I used JSON file instead of text.

Here is my code

exec(http(“Query (direct)…”)  
.postnode)  
.body(ELFileBody(“payloads/elastic\_search\_query.json”)).asJSON

Thanks,  
Vrushalee Ajotikar

---

<div class="post-metadata">

**Author:** ![CyberNinja](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@CyberNinja](https://community.gatling.io/u/CyberNinja)\
**Post date:** [August 25, 2016, 2:17am UTC](https://community.gatling.io/t/unable-to-post-request-body/3202/4 "2016-08-25T02:17:36Z")

</div>

Correction: ELFileBody → ElFileBody

(L is lowercase in El)
