Reputation: 11
I want to upload an image with put method in JMeter. Based on chrome-network, I set the same header and body data in JMeter. header manager:
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryMByG8MgRZu8H9cSQ
Body data
------WebKitFormBoundaryMByG8MgRZu8H9cSQ Content-Disposition: form-data; name="avatar"; filename="1.jpg" Content-Type: image/jpeg
------WebKitFormBoundaryMByG8MgRZu8H9cSQ--
But NoHttpResonseException
appears in jmeter.
Could anyone do me a favour? Thanks.
Upvotes: 1
Views: 1490
Reputation: 339
for this part, I suggest you to try doing your action from postman. And if it is successful you just need to record action performed by postman via jmeter(Http(s) test script recorder). And then configure your jmeter accordingly later. I had a similar issue and I followed above approach. Thanks
Upvotes: 0
Reputation: 168072
Copying request body form the other tool won't help in case of file upload as these multipart requests are different beasts. Particularly in your case the relevant configuration would be:
Post
use multipart/form-data
boxAdd the following parameter:
1.jpg
if the file is present in JMeter's "bin" folder, otherwise - full path to the fileavatar
MIME type of the file, being uploaded, in your case it is application/jpeg
See Performance Testing: Upload and Download Scenarios with Apache JMeter article for comprehensive explanation on how to upload and download files in your JMeter web tests.
Alternative option of building the relevant request is just recording it using JMeter's HTTP(S) Test Script Recorder, in this case make sure 1.jpg
file is present in JMeter's "bin" folder during test recording and execution.
Upvotes: 1