POST request in Gatling
In case it helps anyone else, I was trying to set a custom boundary when Gatling already does this. Here's what solved my problem:
.exec(http("Post document: upload the file")
.post("/api/data/files?revisionId=${documentRevisionId}&uploadType=read_only_file&fileType=application%2Fpdf&fileName=testdocument.pdf&fileSize=10080©ToEditable=true") // ensure testdocument.pdf is in user-files/bodies
.headers(Headers.headers_6)
.formParamMap(Map(
"resumableChunkNumber" -> "1",
"resumableChunkSize" -> "1048576",
"resumableCurrentChunkSize" -> "10080",
"resumableTotalSize" -> "10080",
"resumableType" -> "application/pdf",
"resumableIdentifier" -> "${documentUuid}",
"resumableFilename" -> "testdocument.pdf",
"resumableRelativePath" -> "testdocument.pdf",
"resumableTotalChunks" -> "1"))
.bodyPart(RawFileBodyPart("file", "testdocument.pdf")
.fileName("testdocument.pdf")
.transferEncoding("binary")).asMultipartForm)
Although @Chuck's answer is correct, but the minimalistic code would be as simple as
http("Create contentV2")
.post("/some/path")
.header("Content-Type", "multipart/form-data")
.bodyPart(StringBodyPart("changeRequest", changeRequest)).asMultipartForm
.bodyPart(StringBodyPart("payload", ElFileBody(filename))).asMultipartForm
.check(status is 201)
Now we can have multiple things in place of StringBodyPart like RawFileBodyPart, ByteArrayBodyPart etc. more about it here