user7266862
user7266862

Reputation: 11

Jmeter: Cannot upload file with put method in jmeter

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.

enter image description here

Could anyone do me a favour? Thanks.

Upvotes: 1

Views: 1490

Answers (2)

kishor sharma
kishor sharma

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

Dmitri T
Dmitri T

Reputation: 168072

  1. The error you're getting doesn't seem to be connected with the file upload, it tells that JMeter is not able to connect the server so I would suggest testing baseline connectivity first of all.
  2. 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:

    • Switch to the "File Upload" tab of the HTTP Request sampler
    • Set "method" to Post
    • Check use multipart/form-data box
    • Add the following parameter:

      • Filename: 1.jpg if the file is present in JMeter's "bin" folder, otherwise - full path to the file
      • Parameter Name: the name of the file input, in your case it is avatar
      • MIME type of the file, being uploaded, in your case it is application/jpeg

        JMeter Multipart File Upload

    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

Related Questions