How do I send both file and text in one api request in Jmeter?

252 Views Asked by At

I have to send a post request in JMeter which contains a multipart/form-data body. The request body will contain a file and 2 texts. I tried so many ways to send both files and text in one request but couldn't get the solution. How could I send a file and texts in one request?

enter image description here

enter image description here

1

There are 1 best solutions below

0
Dmitri T On

If you can successfully send the request using the browser or other application like SoapUI - just record the request using JMeter's HTTP(S) Test Script Recorder.

The only thing to remember is to copy the file you're uploading to JMeter's "bin" folder prior to uploading, this way JMeter will be able to properly intercept the request and generate appropriate HTTP Request sampler and HTTP Header Manager.

Alternatively you can generate the request payload manually via "Body Data" tab of the HTTP Request sampler, in this case you need to inspect the API contract and learn how to properly build the request. An example implementation can be found in the Testing REST API File Uploads in JMeter article