how to upload a.zip file in Jmeter? - jmeter

I am unable to upload a .zip file from Jmeter.
Upon trying to upload the file i am getting an error like below,
{
"args":[
"unsupportedMediaType"],
"message":"Request media type is not supported",
"messageId":"unsupportedMediaType",
"correlationId":"6539cd74-5f09-473c-40d2-36f98c0a472b",
"causes":[
],
"status":415
}
HTTP Method supported: POST.
Request header:
Content-Type: application/json; charset=UTF-8
Can anyone please help me in uploading the .zip file from the Jmeter, refer to the below image for my request,
Thanks in advance.

Are you sure about your content-type and what you are doing ?
for zip content type application/json is wrong.
fileToString will try to transform byes(zip) to text which cannot work
Try
checking Use multipart/form-data for Post
and Browser compatible headers .
remove FileToString call and use last tab Files upload instead of body data. And use there the content type application/zip or something suitable
If you are trying to upload a file and send a body, you may need to use nightly build.

Related

Jmeter file upload using PUT not working

I am trying to upload a file using the PUT method, which is not including the file in the request. I have followed the other example POST methods, but considering PUT does not allow multipart to be checked, that might be the issue.
I am also using:
* httpClient4
* jmeter 3.3
screenshot : https://www.evernote.com/shard/s126/sh/b4ebf947-c7e4-4e0a-9ebf-8e42a5f5d082/6813671cb2ab7419
Request data:
PUT http://myurl----here/app_path/test__16525587b4361f339ca33a9cdf0e9201d90e76dc__1676871c-71b8-488a-9750-29554a4be722
PUT data:
[no cookies]
Request Headers:
Connection: close
Content-Type: application/octet-stream
Content-Length: 0
Host: int-cloudstore-perf.svc.netspot.com.au
User-Agent: Apache-HttpClient/4.5.3 (Java/9.0.1)
Your test does't seem to be sending anything as your Put data should not be blank.
I would recommend to remove data from the Parameter Name section of the "Files Upload" tab of the HTTP Request sampler as PUT method is different and it doesn't assume submitting an HTML form and most probably your request will start working as expected (at least it will send data to the server)
Just in case check out Testing REST API File Uploads in JMeter article

Laravel request file upload with content-type won't work

When I remove content-type from Postman laravel request has the file, but if I add any content type in headers it is null? Problem is that browsers add content-type,and I can not exclude them to make it work? Any ideas? Thanks
You should probably get the Content-Type from the UploadedFile instead:
$request->file('form_input_name')->getClientMimeType();
The content-type of the entire request will be set to something like multipart encoding when you send a file with Postman.
I hope this helps.

Getting error "the request was rejected because no multipart boundary was found" while uploading the file in Jmeter

I have tried to upload the file in jmeter:
Please find below mentioned details which i passed in request,
Http reuest:
POST: http:${server_name}/attachment
1.File Path : D:\localdrive\test_docs\images.jpg
2.Parameter Name:images.jpg
3.MIME Type:image/jpg
Http Header :
1.Accept : / ,
2.Content-Type : multipart/form-data
Response Data :
{"response":"the request was rejected because no multipart boundary was found"}
could anyone please share the solution on the same .
Got it !!!
Make sure that below parameter should be mentioned in HTTP request.
Implementation should be HttpClient3.1 or Java (Don't keep it blank)
Content encoding :UTF-8
"Use multipart/form-data for Post" in HTTP sample should be checked.
In HTTP header (Content-Type : multipart/form-data)
for Parameter-name & MIME-type
e.g. In browser enter F12 & hit the request ,
refer the content in Network tab :
Inside Param u will get request param
for example if param is :
HTML contains= Content-Disposition: form-data; name="file"; filename="images.jpg" Content-Type: image/jpeg
Then Parameter-name :file & MIME-type :image/jpeg should be like this.
& now its work fine ,That's a great relief for me !!!
also thanks Anders for ur answer.
HTML contains=
Content-Disposition: form-data; name="file";
filename="images.jpg" Content-Type: image/jpeg
So i have set =
Parameter-name :file MIME-type :image/jpeg ; In sample request i have already checked "Use multipart/form-data for Post" which i have not mentioned early.
Then also its not work ...
anything else which i missed here
There is a checkbox inside the sampler which uploads the file that says "Use multipart/form-data for Post" which needs to be checked.
If your HTML looks something like this input type="file" name="dataFile" id="fileChooser"/>" your parameter name must be "dataFile" which is the name of the input file field.
You can also use a sniffer tool like fiddler for example or the HTTP/S script recorder JMeter has to capture the request and check the MIME Type for example because I'm not sure if jpg files are "image/jpg" MIME Type
Make sure those are correctly formatted and check out what BlazeMeter says about uploading files

Jersey 2.22.1 FileDataMultiPart Header Issue

Hey at the moment i try to upload some files with the jersey client api 2.22.1. I've analyzed the calls of the cms ui to write my own service. For the upload of files i need to generate following request with jersey:
------WebKitFormBoundarydgCBaM6oYnsWZE56
Content-Disposition: form-data; name="contentItem"
{"id":2858,"properties":[{"id":5604,"alias":"dateiHochladen","value":{"selectedFiles":"uploadjava.PNG"}}],
"name":"testcms.PNG","contentTypeAlias":"DateiHochladen","parentId":2857,"action":"publish","expireDate":null,"releaseDate":null,"templateAlias":"DateiHochladen1"}
------WebKitFormBoundarydgCBaM6oYnsWZE56
Content-Disposition: form-data; name="file_dateiHochladen"; filename="uploadjava.PNG"
Content-Type: image/png
------WebKitFormBoundarydgCBaM6oYnsWZE56--
At the moment i am able to generate the upper field, but i am not able to generate the second one with name and filename. Can someone give me a hint how to do this? I've already tried to set new headers, fields, parts and contentdispositions...

Ruby - open-uri doesn't download a file itself, but just the HTML code of the website

I am trying to use this snippet:
open("data.csv", "wb") do |file|
file << open("https://website.com/data.php", http_basic_authentication: ["username", "password"]).read
end
But instead of the desired CSV file, I get just downloaded the HTML code of the website. What's the problem?
When I access the URL and I am not logged in, then it's displayed the form for login (not the HTTP authentication window).
How to solve this situation?
Thanks
I think you should try out net/http http://dzone.com/snippets/how-download-files-ruby
It's probably because your php script return a response with a mime-type different of text/plain or better : text/csv
please see this related previous response
How to use the CSV MIME-type?
in the PHP Script :
header('Content-Type: text/csv');
header('Content-disposition: attachment;filename=data.csv');

Resources