-1

I am trying to upload photo via Jmeter, below is the sample request:

URL: https://domain/.../signedresources/604a9230-..../resumable?region=US Method: PUT Headers: Content-Type - image/jpeg, image/jpeg Session-Id - 884b03... Content-Range - bytes 0-73580/73581 Content-Length - 73581

In File Upload tab of Jmeter I have checked: Use Multipart/form-data option File Path: /Users/sujata.../Downloads/fish.jpeg Parameter Name: file_upload[]
MIME type: image/jpeg

Now, this request works fine when executed via Postman, and in Postman Content-Length 73581 header is not passed. The file size in bytes is 73581. However while running this request via jmeter Content-Length - 73581 header is automatically added and everytime the value is different, which is ending up with below error:

{"reason":"Chunk-Length mismatch (found: 73800, required:73581)"}

Is there any way to compute the content-length of file which we are going to upload and pass that value in the header?

I also tried explicitely mentioning Content-Length - 73581 in header but still it is not taking this valued and somehow some new value is computed and mismatch error is shown.

Is there any way to bypass this content-length computation by jmeter, or overwrite?

PUT-Request-Jmeter

Content-Type_header_added_by_jmeter

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
Sujata
  • 1
  • 1

1 Answers1

0

Content-Length header stands for the number of bytes in the request body. The request body begins right after the Headers. So if you're uploading just one file and there are no dynamic parts of the request - it should be the same every time you execute the request. However for multipart requests you have the boundary which is random and its length may vary, that explains the eventual differences.

It might be the case Postman sends the file in "raw" mode, i.e. not multipart. In this case you will need to untick Use multipart/form-data box in the HTTP Request sampler.

Going forward if you're able to successfully run the request using Postman you can just record it with JMeter's HTTP(S) Test Script Recorder

  1. Start JMeter's HTTP(S) Test Script Recorder

  2. Import JMeter's certificate into Postman

    enter image description here

  3. Configure Postman to use JMeter as the proxy

    enter image description here

  4. Copy the file you will be uploading to the "bin" folder of your JMeter installation

  5. Run your request in Postman

  6. That's it, now you should have appropriate JMeter configuration for the file upload.

More information: How to Convert Your Postman API Tests to JMeter for Scaling

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Hi Dmitri T, Thank you for your help, however I tried with both the approaches suggested, but none worked for me. - unticked Use multipart/form-data box in the HTTP Request sampler. - Recorded the requests in Postman, however still getting same error. {"reason":"Chunk-Length mismatch (found: 73812, required:73581)"} is there any settings to disable Jmeter not compute the file size/length? – Sujata Jun 15 '22 at 11:21