Reputation: 23
Context of my query: Need to test REST API Put method for uploading a file tool to be used is JMeter.
I can successfully perform the above operation using POSTMAN tool but its not working in JMeter.
Here are the JMeter Request Details; method: PUT Path:path HEADER Content-Type= multipart/form-data; boundary=----WebKitFormBoundary${random}
BODY DATA
------WebKitFormBoundary${random} Content-Disposition: form-data; name="fileUpload"; filename="C:\temp\abc.zip" Content-Type: application/octet-stream
------WebKitFormBoundary${random}--
RESULTS: {"success":false,"errorMessages":"Request did not include an attachment"} Response code = 400
Appreciate if anyone can help or provide a better way to upload a file using PUT method.
Thanks, AB
Upvotes: 0
Views: 1757
Reputation: 168157
My expectation is that you simply don't pass the file you are trying to upload along with the request. If you are building the request manually you will need to add the body of the file to your request using i.e. __FileToString() function. Check out Testing REST API File Uploads in JMeter article for more details.
Also given your request works in Postman you should be able to capture it using JMeter's HTTP(S) Test Script Recorder
Start Postman using JMeter's HTTP(S) Test Script Recorder as a proxy by passing --proxy-server
option to it like:
C:\Users\your_user_name\AppData\Local\Postman\app-x.x.x\Postman.exe --proxy-server=localhost:8888
Upvotes: 0
Reputation: 2978
Use MIME Type: application/zip
Your File Upload settings should look like this in JMeter:
Upvotes: 0