0

I am using JMeter to perform file upload test.

I have created an HTTP request to upload the file but I am getting 400 Error.

Following is the data I am using to perform the test.

  1. File type is PDF
  2. Using post method to upload the file and sending the userid in parameters
  3. Uploading the file from File Upload tab
  4. Checkbox for multipart/form-data box is checked

My Request body is:

POST https://staging-research-integrity-api.morressier.com/v1/submissions/files

POST data:

--IaDEVyB276251zmfsTsTZbo4qJrbOC4A8Rwttjt
Content-Disposition: form-data; name="userId"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

64dcc16ac7ef810012d6a8c6
--IaDEVyB276251zmfsTsTZbo4qJrbOC4A8Rwttjt
Content-Disposition: form-data; name="file"; filename="RP1.pdf"
Content-Type: application/pdf
Content-Transfer-Encoding: binary

<actual file content, not shown here>
--IaDEVyB276251zmfsTsTZbo4qJrbOC4A8Rwttjt--


[no cookies]

MY Request headers are:

Connection: keep-alive
Accept: */*
Content-Length: 621888
Content-Type: multipart/form-data; boundary=UkEG1Dv4nXfBZYR9Xp5fc9X4hMf3iFCRjZGh
Host: staging-research-integrity-api.morressier.com
User-Agent: Apache-HttpClient/4.5.14 (Java/18.0.2.1)

[![HTTPS REQUEST][1]][1]
[![FileUpload tab][2]][2]

However same request is getting sent through the postman successfully with the following data

[![POSTMAN REQUEST][3]][3]
[![Postman Header][4]][4]


  [1]: https://i.sstatic.net/iFp9U.png
  [2]: https://i.sstatic.net/CHixs.png
  [3]: https://i.sstatic.net/G8fxo.png
  [4]: https://i.sstatic.net/QNx7Z.png

1 Answer 1

0

Most probably you need to sync HTTP Headers, i.e. add Accept-Encoding and remove Content-Type

In general be aware that it's possible to just record the request using JMeter's HTTP(S) Test Script Recorder

  1. Start HTTP(S) Test Script Recorder

  2. Configure Postman to use JMeter as the proxy

    enter image description here

  3. Import JMeter's certificate into Postman

    enter image description here

  4. Copy RP1.pdf file to "bin" folder of your JMeter installation

  5. Run your request in Postman

  6. JMeter will generate the appropriate HTTP Request sampler and HTTP Header Manager and you should be able to successfully replay the request

More information: JMeter Performance Testing: Upload & Download Scenarios

1
  • Thanks alot, my issue got fixed by using the Test Script Recorder and recording the request from postman. Commented Sep 28, 2023 at 7:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.