How to use RawFileBody to post a json file


I am trying to write a load test to do a POST to an endpoint using a raw body.

I have a json file which I would like to use to test the POST call. It’s something like

“x_content”: “12”,
“z_content”: “34”,
“a_content”: [


and it’s currently saved in the /data directory. Upon running the test it can’t seem to find my test file and after reading the Gatling document, it says all files should be uploaded in the /bodies directory.Do I need to create this directory manually? If so, what should the classpath be?

Here is an example of my test:

http(“post data”)

from conf/gatling.conf

directory {
#data = user-files/data # Folder where user’s data (e.g. files used by Feeders) is located
#bodies = user-files/bodies # Folder where bodies are located
#simulations = user-files/simulations # Folder where the bundle’s simulations are located


so keep your json file in user-files/bodies folder.

Ok so I have manually created a bodies folder under resources as my data folder is in resources as well but when i run the test i still get a 'file my_request.json doesn’t exist ’ error.

You can try following:

.exec(http("Set") .post("/") .body(StringBody("""{"location" : {"address" : {"country" : "USA",},}}""")).asJSON

the bodies directory has to be in user-files folder. If you don’t want that, just change gatling.conf to point the bodies directory to the directory that contains your jsons.