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

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.

Related

JMeter view results tree requests showing error

Why is this second request happening (Request2-1) here and how to solve it.
Your request is redirected and there is not permission to access the resource.
The HTTP 403 Forbidden client error status response code indicates that the server understands the request but refuses to authorize it.
Please check the request details in the view result tree by clicking Request->Request Body and Request->Request Headers
You need to ensure that the request is permitted.
Most probably the resources, you're trying to access require authentication and you're not supplying valid authentication context.
If you do HTTP Status Code 403 means that the user is not allowed to access the endpoint.
See How to use JMeter for Login Authentication article for more information on example bypassing login challenge in JMeter tests.
If "Follow Redirects" is selected in HTTP Request, it will follow the redirects and groups each redirect under the original request as in the image you posted.
Some APIs can redirect, this is normal. Response failure is caused by the request content sent. Check the parameters and body values you sent.

Redirect issue jmeter for 301 and 302

I fired one URL on which redirection is expected but I am getting different response code in jmeter and on using devtools that is f12.
Example
Fired http://test.com on chrome, on using f12, i can see response code as 301 and in second line it displays 200 as successful redirection happened.
But, when same URL fired through jmeter, i got response code as 302(Found)
Right now, i have used HTTP request
Implementaion: No client selection(default),
GET,
Protcol - http and proxy server details.
Can you please let us know why we are able to see difference in response code when we fire that URL directly on chrome(301) and through jmeter(302)
Ensure that "Follow Redirects" is checked in your HTTP Request:

Response Data for "GET Method"

I am creating different HTTP Requests for a site and taking an access token as a variable from Regular Expression Extractor and using it in another HTTP Request.
The Thread group is working fine; i.e. no error in View Results Tree. But Response data is only coming for the Request with POST Method. Nothing is coming for the Request with GET Method and both requests are taking the access token properly.
In some cases you may get response code 200 ok and request still may fail. In case of your get request that seems to be happening.
Check following:
Headers being sent with get request. (Compare request being sent from JMeter and from real browser.)
Add response assertion to get request to be assure the correctness of the response. (Check what response you get for the request made from browser.)
Make sure you have added cookie manager in the test plan.

when sending json request to server I am getting forbidden 403

I am learning jmeter.
I am passing json request in Body of http request. I set content-type as application/json. passing cookie value using cookie manager. I am getting response code as 403. how to resolve it??
I have passed all the headers which is caputred in Firebug.. Only the difference is the captured cookie in the firebug has lot of values but when i run the test, the below only is passing (if I use, Cookie Manager) other than that all are same.. No clue why it is returning 403..
Cookie Data:
connect.sid=s%3AFBcljlVYI2p1WyjuxcDgWQKJ.kSrLYIsSy9T%2FEgSB25yUq0T3qTjpqF69GJhyW9GzJpU; TOKEN=ZU3cf9fKGCPJXM6qi7JX6DVv2%2B3Jw8q%2Flnb2A%3D
403 is a "Forbidden" error. Most likely is that something needs to be sent in the body of your http request, like a token, which needs to be extracted from the log in request.
Add Http authorization manager, specify the url along with the crednetials in it. Keep the encoding mechanism to BASIC_DIGEST. Enable log viewer so that you can trace the exact issue

codeception get request with if-none-match does not return 304

i am using codeception for the code coverage of a REST API. In my current case, i want to test the behaviour of sending a request to receive an ETag-Header for the requested resource and reuse the value of this ETag in a second request on the same resource with the header "If-None-Match" to achieve a 304 response code.
So what I am doing in my Cest-File is:
// send first request, grab etag
$I->sendGET('/myresource');
$I->seeResponseCodeIs(200);
$I->seeHttpHeader('ETag');
$eTag = $I->grabHttpHeader('ETag');
// send second request with header "If-None-Match" containing the etag
$I->haveHttpHeader('If-None-Match', $eTag);
$I->sendGET('/myresource');
$I->seeHttpHeader('ETag');
$I->seeResponseCodeIs(304);
When I execute this test it fails after the second request saying that response code 200 does not match 304.
When I execute the same request with an external tool (HTTP Requester Plugin for Firefox), i get the expected behaviour. What do i have to do to get my tests working? Am i mssing something on the codeception side or may this be a bug?
Any help is appreciated, maybe someone already had this scenario before.
Thanks in advance for your help!

Resources