Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading file to rest API using JMeter

Note - I have checked BlazeMeter Tutorial which uploads doc as Body Data while I use File Upload tab.

Here is how my request looks -

enter image description here

On execution I get following Request -

POST https://xxx

POST data:
<actual file content, not shown here>

[no cookies]

Request Headers:
Connection: keep-alive
Content-Type: multipart/form-data
Accept-Language: en-US
Authorization: bearer <>
Accept: application/json
Content-Length: 78920
Host: test-host
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_102)

And the request fails with 400 error -

Response code: 400
Response message: Bad Request

Since I am able to carry out file upload using curl, I assume that I missed the some configuration with JMeter. Curl looks as -

curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Bearer <>' -F upload_file=@"test.pdf"  'https://xxx'

What did I miss in JMeter file upload?

like image 610
Tarun Avatar asked Aug 11 '26 15:08

Tarun


1 Answers

Another vote for using the Java implementation in the Advanced tab in Jmeter. My headers and body were exactly the same between postman and jmeter, but it wouldn't upload my file (got response code 415) until I changed to the Java implementation.

like image 69
JapethMarvel Avatar answered Aug 14 '26 10:08

JapethMarvel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!