JMeter File Upload Scenario

59 Views Asked by At

I am trying to create a HTTP request that send both Json and File.

Sample Payload format:

------WebKitFormBoundaryooARNALDyzj0QAAl Content-Disposition: form-data; name="case"; filename="blob" Content-Type: application/json

{Json-Data} ------WebKitFormBoundaryooARNALDyzj0QAAl Content-Disposition: form-data; name="files"; filename="Test.txt" Content-Type: text/plain

------WebKitFormBoundaryooARNALDyzj0QAAl--

Above one is the format of the Payload.

When I try to run the script the HTTP request failing , the reason is , the JSON part is removed only the file part is sent in a payload.

Payload sent in the request:

--mKcQTUa2-T28YDq4lnQyGCl8ksaViUMuIjO Content-Disposition: form-data; name="files"; filename="TestViewer.txt" Content-Type: text/plain Content-Transfer-Encoding: binary

<actual file content, not shown here> --mKcQTUa2-T28YDq4lnQyGCl8ksaViUMuIjO--

1

There are 1 best solutions below

4
Dmitri T On

I think you should set up your HTTP Request sampler like this:

enter image description here

and you will be able to see the request details without files contents in the View Results Tree listener and file content in jmeter.log if needed:

enter image description here

Also be aware that you can just record your request using browser (or other application) and HTTP(S) Test Script Recorder.

More information: JMeter Performance Testing: Upload & Download Scenarios