# rawFileBody and rawFileBodies

**URL:** <https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393>\
**Category:** Gatling (Open-Source)\
**Created:** [January 15, 2022, 6:27am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393 "2022-01-15T06:27:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaghavPal](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@RaghavPal](https://community.gatling.io/u/RaghavPal)\
**Post date:** [January 15, 2022, 6:27am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393/1 "2022-01-15T06:27:08Z")

</div>

I am using latest Gatling 3.7.3 (open source)  
I am trying to create a POST request and need to get the json body (payload) from a file

val _scn_ = scenario(“Post API Demo”)

.exec(  
http(“Create User”)  
.post("/users")  
.asJson  
.header(“content-type”, “application/json”)  
.body(_rawFileBodies_("./data/createuserdata.json")).asJson

As per the documentation we can use **rawFileBody** function, but it is **not available** instead we have **rawFileBodies** , how to use it and what will be the best way to get request body from file

---

<div class="post-metadata">

**Author:** ![Bharath\_Marrivada](https://avatars.discourse-cdn.com/v4/letter/b/ecccb3/32.png) [@Bharath\_Marrivada](https://community.gatling.io/u/Bharath_Marrivada)\
**Post date:** [January 15, 2022, 9:34am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393/2 "2022-01-15T09:34:22Z")

</div>

Try the following  
.body(RawFileBody(“ccp/ccpupload/send\_request.json”))

---

<div class="post-metadata">

**Author:** ![Bharath\_Marrivada](https://avatars.discourse-cdn.com/v4/letter/b/ecccb3/32.png) [@Bharath\_Marrivada](https://community.gatling.io/u/Bharath_Marrivada)\
**Post date:** [January 15, 2022, 9:58am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393/3 "2022-01-15T09:58:15Z")

</div>

I am using Java 17, Gatling 3.7.3, IntelliJ, Windows. Following is the sample code.

http(“Create User”)  
.post("/users")  
.header(“content-type”, “application/json”)  
.body(RawFileBody(“ccp/data/createuserdata.json.json”))

---

<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:** [January 15, 2022, 10:58am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393/4 "2022-01-15T10:58:53Z")

</div>

In short :

1. The documentation states RawFileBody with a capital R.
2. The documentation states to use a classpath path, not a relative filesystem path

---

<div class="post-metadata">

**Author:** ![RaghavPal](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@RaghavPal](https://community.gatling.io/u/RaghavPal)\
**Post date:** [January 20, 2022, 2:59am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393/5 "2022-01-20T02:59:30Z")

</div>

Thanks a lot for the help Bharath and Stéphane.  
The issue was indeed the use of capital R, it would have been great if it shows the options in auto-suggestion list  
Other thing is, I was able to run with relative path as shown below

.body(RawFileBody(“data/createuserdata.json”))

Here, data folder is under src/test/resources, hope can help others

Raghav

---

<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:** [January 20, 2022, 9:21am UTC](https://community.gatling.io/t/rawfilebody-and-rawfilebodies/6393/6 "2022-01-20T09:21:21Z")

</div>

> Other thing is, I was able to run with relative path as shown below

Making things clear: no, “data/createuserdata.json” is not a relative path on the filesystem.  
This is a Java classpath location. And the classpath separator is always “/” whatever the OS, even on Windows.
