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
Related
I have a login page in an Oracle Apex application that works fine with a normal web browser like chrome. However when i try to perform the same operation using CURL (command-line browser), a HTTP 404 error is returned:
Request:
curl -i -d "P9999_USERNAME=MOIZ&P9999_PASSWORD=xxxx" -X POST http://localhost:8080/apex/f?p=101:9999:0:
Response:
HTTP/1.1 404 Not found
Server: Oracle XML DB/Oracle Database
Content-Type: text/html
Transfer-Encoding: chunked
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not found</TITLE>
</HEAD><BODY><H1>Not found</H1>
The requested URL /apex/f was not found on this server</BODY></HTML>
Using a normal browser, there are two sever request: one GET and one POST. However when using curl i am just making a single POST request.
Is that difference the cause of problem?
Is it possible to POST apex page without calling GET?
If yes then whether this solution will also work for file uploads?
Based on the post Python web scraping with BS using correct url? I was able to get answer to my above questions. [although this post uses python's requests and BeautifulSoup libraries for demonstration purpose, I think with some shell/windows scripting it may also be achievable with curl too]
Is that difference the cause of problem?
For POST request in APEX, we need to first perform a GET request as APEX expects the following hidden items to be sent as a payload of POST request
p_flow_id # application id
p_flow_step_id # page id
p_instance # session id
p_page_submission_id # page submission id
p_request # request
p_md5_checksum # md5 checksum
p_page_checksum # page checksum
p_arg_names # list of arguments
In addition, you may also need to add your page specific input items. For example,
p_t01 # username
p_t02 # password
Is it possible to POST apex page without calling GET?
For reasons mentioned in above answer, GET request will be required before POST request can be performed.
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.
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
How can I get JMeter to only attempt 1 url instead of 5 each time I run a test?
I am using a different site which is internal, but let's say I was using "blah.com" for the sake of discussion.
I see this in the View Results Tree:
http://blah.com
https://blah.com
https://blah.com/abc
http://blah.com/abc
https://blah.com/abc
In the same order, here are my http response codes:
301 Moved permenantly
301 Moved permenantly
302 Found
301 Moved permenantly
200 Ok
If I want Jmeter to just go straight to the 5th one so that I get the 200 code right away, what do I have to do in JMeter settings?
I have:
HTTP Cookie Manager
HTTP Cache Manager
HTTP Request ( with "blah.com" filled in for the server name )
under HTTP Request, I have all of these:
HTTP Header Manager
Response Assertion ( with some url patterns checking for html tags - I just copied the html from View Source and pasted it in as a url pattern...these all seem to work )
Response Assertion ( just checking response code - I chose Response Code and entered "200"...this also seems to work )
Summary Report
I was able to get this down to 1. Adjustments made to the HTTP Request:
I added "/abc" to "Path" and changed "Follow Redirects" to "Redirect Automatically".
I have a program that uses an XMLHTTPRequest to gather contents from another web page.
Problem is, that web page has cloaking custom errors set-up (ie. /thisurl doesn't literally exist as a file on their web server, it is being generated by the custom 404 error file.), so its not returning the page it shows in the browser, instead its showing its default 404 error response from that custom error page, in my HTTPRequest response.
By using this website http://web-sniffer.net/ I have narrowed down what the problem may be, but I don't know how to fix it.
Web-sniffer has 3 different versions to submit the request:
HTTP version: HTTP/1.1
HTTP/1.0 (with Host header)
HTTP/1.0 (without Host header)`
When I use HTTP/1.1 or HTTP/1.0 (with Host header) I get the correct response (html) from the page. But when I use HTTP/1.0 (without Host header) it does not return the content, instead it returns a 404 error script (showing the custom error page).
So I have concluded that the problem may be due to the Host header not being present in the request.
But I am using MSXML2.XMLHTTP.3.0 and haven't been able to read the page using HTTP/1.1 or HTTP/1.0 (with Host header). The code looks like this:
Set objXML = Server.CreateObject("MSXML2.XMLHTTP.3.0")
objXML.Open "GET", URL, False
objXML.setRequestHeader "Host", MyDomain '< Doesnt work with or w/out this line
objXML.Send
Even after adding a Host header to the request, I still get the template of the 404 error returned by that custom error script in my response, the same as HTTP/1.0 (without Host Header) option on that web-sniffer site. This should be returning 200 OK like it does on the first two options on web-sniffer, and like in a web browser.
So I guess my question is, what is that website (web-sniffer.net) able to get the proper response with their first two HTTP version options, so I can emulate this in my app. I want to get the right page, but its only returning the 404 error from their 404 error template.
In response to an answerer, I have provided screen shots from 2 seperate cUrl requests below, one from each one of my servers.
I executed the same cURL command, same url (that points to a site on the main host), which is cURL -v -I www.site.com/cloakedfile . But looks like its not working on the main server, where it needs to be. It can't be a self-residing issue, because from secondary to secondary it works fine, these are both identical applications/sites, just different ip's/host names. It appears to be an internal issue, that may not be about the application side of things.
I dont have any idea bout MSXML2.XMLHTTP.3.0. But from you problem statement i understand that the issues is certainly due to some HTTP header field that is wrongly set or missed out in your request.
By default HTTP 1.1 clients set Host header. For example if you are connecting to google.com then the request will look like this
GET / HTTP/1.1
Host: google.com
The "Host" header should have the domain name of the server in which the requested resource is residing. Severs that has virtual hosting will get confused if "Host:" header is not present. This is what happens with groups.yahoo.com if you havent specified Host header
$ nc groups.yahoo.com 80
GET / HTTP/1.1
HTTP/1.1 400 Host Header Required
Date: Fri, 06 Dec 2013 05:40:26 GMT
Connection: close
Via: http/1.1 r08.ycpi.inc.yahoo.net (ApacheTrafficServer/4.0.2 [c s f ])
Server: ATS/4.0.2
Cache-Control: no-store
Content-Type: text/html; charset=utf-8
Content-Language: en
Content-Length: 447
And this should be the same issue you are facing with. And also make sure that you are sending the domain name of the server from which you are trying to fetch the resource. And the Host header should have a colon ":" to delimit the value like "Host: www.example.com".