Gatling file upload

Hi All ,
Hi have created gatling framework to verify performance .
I am stuck at one point .
I want to upload xml file for post request .
I am not able to upload file.
I have tried following multiple approaches .
1.bodyPart(RawFileBodyPart(“./src/test/resources/Data/Burp.xml”))
2.formUpload(“Burp”, “./src/test/resources/Data/Burp.xml”)
3.body(RawFileBody(filePath = “./src/test/resources/Data/” + “Burp.xml”)).asMultipartForm
4.formUpload(“Burp.xml”, “./src/test/resources/Data/”)
5.bodyPart(RawFileBodyPart(“./src/test/resources/Data/Burp.xml”).contentType(“multipart/form-data”).fileName(“Burp.xml”))
6.bodyPart(StringBodyPart(“Burp.xml”, “./src/test/resources/Data/Burp.xml”).contentType(“multipart/form-data”).fileName(“bugcrowd.xml”))
7.bodyPart(StringBodyPart(“Burp.xml”,“./src/test/resources/Data/Burp.xml”))
8.body(RawFileBody(“./src/test/resources/Data/Burp.xml”))
9.bodyPart(RawFileBodyPart(“./src/test/resources/Data/Burp.xml”, “./src/test/resources/Data/Burp.xml”).fileName(“./src/test/resources/Data/Burp.xml”)
.transferEncoding(“binary”)).asMultipartForm

Still I am getting 500 error
I want to achieve following that I have achieved in post

Hi @Tejas,

What an impressive list of tests :clap:

Did you try to express that the body part is of XML content type?

Something like:

    ChainBuilder postFile = exec(
            http("Send file").post("/api/file-upload")
                    .bodyPart(RawFileBodyPart("Data/Burp.xml").contentType("application/xml"))
                    .asMultipartForm()
    );

Note:

  • In a “multipart” form, each part should have its own content-type.
  • Avoid file path relative to your project architecture (when compiled as jar, your simulation won’t find the path, as src/test/resources is directly at the root of the built jar)
  • Did you succeed to upload via curl? (I’m not sure what postman does under the hood)
  • “500” is “Internal Server Error” => not very useful. As you are pretty sure the request is faulty, it should response with “400 Bad Request”

Hope it helps!
Cheers!

Hi @sbrevet
Thanks for reply .

I also tried -
.bodyPart(RawFileBodyPart(“Data/Burp.xml”).contentType(“application/xml”))
.asMultipartForm

Still i am getting 500 error

And can we see full request log from postman? (list of headers, format of body, etc.)

Cheers!

Which version of Gatling are you using?

yes it on succeed on post man.
Format of body is added in screenshot of first comment
In body I have uploaded file under form-data

@slandelle Hello ,
I am using following version
<gatling.version>3.6.1</gatling.version>
<gatling-maven-plugin.version>3.1.2</gatling-maven-plugin.version>

This version is very outdated. There’s a very good chance that your issue has been fixed since then.
Please upgrade to:

<gatling.version>3.9.5</gatling.version>
<gatling-maven-plugin.version>4.3.7</gatling-maven-plugin.version>

Make sure to check the official demo project for maven + Scala.

If you still experience an issue after upgrading, please provide a reproducer so we can investigate, see How to Ask a Question.

Hey @sbrevet @slandelle
Issue got resolved .
Just added ?isBase64=false at end of api .

Thanx for the help
Cheers!!!