1
votes

I'm new to JMeter and trying to put a file to our API using an HTTP Request. When I put the file via curl using the -F flag, it works no problem.

Here's my curl request:

curl -X PUT -u uname:pword https://fakehostname.com/psr-1/controllers/vertx/upload/file/big/ADJTIME3 -F "upload1=@ADJTIME" -vis

and here's the relevant part of the response from the server:

> User-Agent: curl/7.37.1 Host: myfakehost.com Accept: */*
> Content-Length: 4190 Expect: 100-continue Content-Type:
> multipart/form-data; boundary=------------------------d76566a6ebb651d3

When I do the same put via JMeter, the Content-Length is 0 which makes me think that JMeter isn't reading the file for some reason. I know the path is correct because I browsed to the file from JMeter. Litte help?

2
Does it make a difference that JMeter is pointing to ADJTIME4 and the curl output is ADJTIME3? Also I noticed you are missing the username and password setup in JMeter, and the procotol is set to http, not https. The Path field should not include the scheme...maybe you should have a run through some documentation on JMeter. - Burhan Khalid
No it doesn't matter. I successfully posted to ADJTIME3 (our api names the file based on the posting URL, so posting to ADJTIME4 would save the file by that name). We use Bearer tokens for authorization so I put the authorization in the Header Manager. I have read the documentation thoroughly and have run a few load tests against our API, so I'm not a total newbie. Again, I have no problem getting access to our API. The problem (as stated in the original post) is that JMeter is not reading the file (Content-Length: 0) - Walker Mellema
You are missing the MIME Type, try application/octet-stream - Burhan Khalid
I actually put the type in the header manager as well. Our API is expecting multipart/form-data (but I tried your suggestion hoping it would work). Here's the Content-Type from the header manager: Content-Type: multipart/form-data; boundary=d76566a6ebb651d3. In the file that's supposed to upload, the first line is --d76566a6ebb651d3 and the last line is --d76566a6ebb651d3-- - Walker Mellema

2 Answers

0
votes

In File Upload, make your file path RELATIVE to .jmx file or place next to it and specify file name only.

0
votes

Thanks to everyone who offered solutions and suggestions. It turns out that the API I was trying to load test was the issue. I can PUT a file via curl no problem, but there's something about the Jmeter PUT that the API does not like. I finally tried doing a PUT to an unrelated API and was successful.