Missing location header in redirect for GET in Jmeter

1.3k Views Asked by At

I am trying to test the login part of the application and here are the steps I tried in Browser,

  1. Navigate to Home page 2.Enter credentials and click on login.

once I click on Login, a redirection happens to "\home" URL.

I recorded the scripts and when I replayed it, the I can see that "Navigation to HomePage" doesn't have any issues. The second step where I click on login redirects me to another URL "\home" with response as "302 found".

The redirection URL Sample "\home" which is executed as sub sample of the login URL, returns an error message "Missing location header in redirect for GET" with response code as "307 Temporary redirect".

The redirection URL should return me a token as response and so that I can proceed with further steps but I am not sure what it means by "missing location header".

I checked the same in fiddler, browser (dev tools), I found that the redirection URL has a cookie(Session ID) sent in request Header. Whereas in Jmeter recording it is sent in Request body. That is the only difference I can see.

I also tried installing the latest version of Jmeter, New certificate and checked the cookie manager, inserted the missing header in the header manager of the "Login URL" nothing works.

since it seems to be working in Fiddler, i assume it should be some issue related to tool and not the application

Can someone help me what this issue is and if I need to pass the cookie data in request header instead of request body, how do I do it for a redirection URL which appears only during execution and not during recording.

attachment :enter image description here

1

There are 1 best solutions below

3
Dmitri T On

JMeter's HTTP Cookie Manager automatically handles cookies, to wit:

  • Extracts them from the Set-Cookie header
  • If hostname and path of the next request match, the cookie is not expired, etc. - JMeter automatically adds Cookie header with the relevant cookie(s)

If you're confused with View Results Tree listener output like this:

enter image description here

in fact JMeter generates proper Cookie header, you can double check it by replaying your script via Fiddler (or using other sniffer tool)

If you additionally need to send another header with the value of the cookie from the previous request you can:

  1. Add the next line to user.properties file:

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick up the change

  3. Add HTTP Header Manager to your test plan and configure it to send the header you need with the value of ${COOKIE_your-cookie-name-here}

    in my case it will be ${COOKIE_AEMDC}

More information: HTTP Cookie Manager Advanced Usage - A Guide