1

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.

1
  • please add Request from both Chrome-Network and HTTP Request sampler? Commented Dec 9, 2016 at 5:30

2 Answers 2

1
  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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.