JMeter HTTP Request: Always Sending GET Method - jmeter

All,
Every HTTP Request I make to my test REST Service is sent with the method set to GET. Tomcat rejects with a 405 - Unsupported Method. Doesn't matter what I change it to (POST, PUT, etc) Jmeter always sends a GET.
I set up the simplest possible test case by creating a Threadgroup with an HTTP Request Sampler and a View Results Tree. I send a JSON body to the REST Services which just echos back the request along with an ID. Works great with Google's REST Client UI.
Here is the result from the View Results Tree:
Response code: 405
Response message: Method Not Allowed
Response headers:
HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
Allow: POST
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1045
Date: Fri, 18 Jul 2014 21:39:27 GMT
Here is the RequestMapping from my REST Service
#RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
Here are some screenshots from my results. I wonder why there are two URI's below the HTTP Request in the tree? Notice the POST request looks correct.

Since the right answer is not provided yet: It's the "Follow Redirects" Option that causes this behavoir under certain circumstances.
see http://www.sqaforums.com/showflat.php?Cat=0&Number=687068&Main=675937

Try to end the 'Path' value of HTTP Request with '/'. It has to remove the GET result in View Results Tree.

I had the same problem. I tried everything also I read this question and all answers before find the thing that worked for me.

Content-Type should be application/json. It can not be text/html.
Set that in HTTP Header Manager. I assume you have set authentication details correctly.

We need to have three things properly set.
Content type which will be application/json
set the endpoint correctly in the path ,which you can see in soup ui
Check the port number on which the api wil get run on [All this u can first check on soupui and then try running the same in jmeter

Related

Ruby HTTP request always returns 403 response (too many requests). Works in Postman/browser

I am trying to write a simple function which would easily extract the contact information from a classified listing.
Background
The URL I'm looking at is
https://www.idealista.pt/imovel/27542922/
Looking through the developer tools in Chrome, I see that it makes a GET request to this URL. https://www.idealista.pt/pt/ajax/listingController/adContactInfoForListing.ajax?adId=27542922
If I make a GET request in Postman or just copy the second URL into Chrome I get a JSON containing various details.
My code
(Ruby)
uri = URI('https://www.idealista.pt/pt/ajax/listingController/adContactInfoForListing.ajax?adId=27542922')
foo = Net::HTTP.get(uri)
JSON.parse(foo)
The problem
The response is a 403 with a body saying that the system has detected that many requests have been made in a short period of time.
I can replicate this in Postman by doing seven or eight consecutive requests, but then if I wait a minute or two before trying again I get back to seeing the JSON.
Through Ruby it happens straight away.
What I've tried
I've tried copying some or all of the temporary headers created by Postman into my request in Ruby but I still get the same error or 404
User-Agent - PostmanRuntime/7.22.0
Accept - */*
Cache-Control - no-cache
Postman-Token - 6c68a9eb-83d5-4724-9f41-3fc51971db9f
Host - www.idealista.pt
Accept-Encoding - gzip, deflate, br
Cookie - userUUID=c017919a-6115-4905-95b3-5d949c6fb447; _pxhd=34ed938caca242bf6050147e1514cda07b704cc7681245a4beec5a64e0a5cf66:d4f21381-522a-11ea-a954-6f59910ff05b; SESSION=887b6dbc-78a4-4abd-9600-7ce401507331; WID=15a353ca7aab3446|XlEN6|XlEN4
Connection - keep-alive
you have to use a proxy, and chanfe the ip

Response for Preflight occuring only for application/json

I have been trying to do a post request from angular 5 to my spring mvc backend. However, I am getting the Response for preflight is inavlid(redirect) error message. I have been looking around for solution since 4 days but with no success. I have tried all suggestions setting the content-type headers. While doing that, I am observing one unusual thing. The preflight error is occuring only when I am setting the content-type header is set to application/json. If I set the header to text/plain the preflight error is gone but 415 unsupported media type error is being displayed. I have been really digging up stuff to get some help. Any help or suggestions are much appreciated.
Using chrome, look at Developer tools - console and see the exact error.
Your service is not setting preflight response correctly for your OPTIONS request.
How can i verify if my service is CORS ready
use PostMan or RestClient and make an OPTIONS request with nothing else (no auth, nothing)
Look for Response headers for OPTIONS request from Step 1.
Response headers may look like this
Access-Control-Allow-Origin: http://exampledomain.comg
Access-Control-Allow-Methods: GET, POST (or whatever methods your want to allow)
Access-Control-Allow-Headers: Content-Type
Add crossOrigin Annotation at your controller, if you have more one controller then add on all controller
#CrossOrigin(origins = "*")
#RestController

POST request with Content-Type application/x-www-form-urlencoded and

My requirement is very simple.
Call POST request with id and password.
Header has Content-Type = application/x-www-form-urlencoded
and data is also passed as urlencoded like below
Response is coming in xml format.
I tried a lot of examples from everywhere but nothing seems to be working. It gives me back 401 Unauthorized which is an error that target API throws if request is not in proper format.
http://zetcode.com/java/getpostrequest/
Exactly what I needed.
Java HTTP POST request with HttpURLConnection section on the page did the work.

JMeter POST request is returning 200 OK instead of 302 (redirect)

I'm attempting to login to a website that uses IdentityServer with JMeter but am getting stuck at the point where I post my credentials.
If I inspect the request via fiddler, I can see that it returns a 302 with a redirect, however when I attempt to post the same request in JMeter, I get a 200 with 'Error' in the html with no details.
This is my request in JMeter....
This is the request in Fiddler....
And this is the HTML response in JMeter (200 OK)...
And this is the Fiddler response...
And this is the HTML response in Fiddler, after the redirect...
I can confirm that my JMeter variables ${COOKIE_idsrv.xsrf} and ${SignIn are populated with the correct values.
Other points to note
I have a HTTP Cookie Manager
The HTTP Manager Referer headers are set correctly
All requests are set to Follow Redirects
I retrieve all embedded resources for each request
Does anybody know what could be the issue here?
In your POST request, why do you have "signin" parameter included?. You have already added "signin" as a query parameter and it appears to be redundant and not required for the actual POST body data. Fiddler does not have it in both the places. Please check.
After much frustration it turned out the issue was due to ${COOKIE_idsrv.xsrf} not containing the correct value for idsrv.xsrf. Once I changed this to pull it from a previous request it seemed to work okay.

JMeter http request works via fiddler but not without

I have a simple thread group with HTTP requests as below:
Do Login - POST request
grab the authorization bearer token
Get eventId - GET request
This is a simple HTTP GET request like this http://server_ip:8080/rest/v1/events/1234567
Pass the authorization bearer token in HTTP Header Manager
When I run the above, the Login post request goes through fine. I get a 200 OK and the response header ad message looks fine.
But the 'Get eventId' request fails and returns a 400 Bad Request.
However when I start JMeter to go through the proxy like below, the 'Get eventId' request returns a 200 OK and the response looks as expected.
jmeter.bat -H 127.0.0.1 -P 8888
I am not sure what I am doing wrong?
As per 400 Bad Request status code description:
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server could not understand the request due to invalid syntax.
Most likely you need to add HTTP Header Manager to send Content-Type header with the value of application/json (or whatever MIME type server expects).
If this is not the case - inspect what is being sent in both cases using View Results Tree listener and amend JMeter configuration so requests would look exactly the same (apart from dynamic token)

Resources