Search code examples
testingfile-uploadjmeterperformance-testing

How to send a csv file upload request from Jmeter


I have a request in which the user uploads a csv file and then the file is validated based on a few criteria. I have captured the request from blazemeter (refer the screenshot of the request captured) Request captured in Blazemeter

But its failing when I hit this using Jmeter. (I am trying to send the exact same request along with the file attached in the "File Upload" option).

I've checked in Developer's tool and the actually request sent is :

------WebKitFormBoundaryBk6Qf9RTb4vFvkKw Content-Disposition: form-data; name="file"; filename="EmployeeCSV.csv" Content-Type: application/vnd.ms-excel

------WebKitFormBoundaryBk6Qf9RTb4vFvkKw Content-Disposition: form-data; name="fileExtension"

csv ------WebKitFormBoundaryBk6Qf9RTb4vFvkKw Content-Disposition: form-data; name="organisationId"

ZUVMbzBudFM5T2Y2bVNtUHFWWmZCRmJhWFZFTkJGMEVuNk9WKzBsQ2dUWT0= ------WebKitFormBoundaryBk6Qf9RTb4vFvkKw Content-Disposition: form-data; name="schemeIdSf"

d0dqVXd5b25wVFArWTFkc3l0dUV5R3V0STlqZ2owVE5FVCtxVGhEZUxESmJydVAzYjBLSkxqdWxLMmQva29WSg== ------WebKitFormBoundaryBk6Qf9RTb4vFvkKw Content-Disposition: form-data; name="fileGUID"

1612429088749 ------WebKitFormBoundaryBk6Qf9RTb4vFvkKw--

Can someone help me out on how can I send the above mentioned request in Jmeter?


Solution

  • The HTTP Request sampler setup doesn't seem correct to me, you need to define the file(s) you're uploading under "Files Upload" tab like:

    enter image description here

    I would recommend re-recording your file upload event using JMeter's HTTP(S) Test Script Recorder, JMeter should be smart enough to generate proper HTTP Request sampler and HTTP Header Manager configuration.

    Just make sure to copy your EmployeeCSV.csv to "bin" folder of your JMeter installation during recording, only this way JMeter will be able to properly capture and build the request. More information: Recording File Uploads with JMeter