How can I get responses from redirections?

Hi all,

I am making a POST request that makes some redirections. First redirection returns 302, second returns 302 and last one returns 200 as status code.

response =
          email: "MY_MAIL",
          password: "MY_PASS",
          __RequestVerificationToken: requestVerificationToken,
          headers: {
            "content-type": "application/x-www-form-urlencoded",
            origin: "MY_ORIGIN",
            "upgrade-insecure-requests": "1",
              "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
              '" Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',

The problem is that, response only gives me the latest status code (200) and the latest response body and headers. I need a token that it is provided in the second redirect, but I have no access to that information. Is there any way to access there? I’m happy with the automatic redirection but I’d like to get that info from the “hidden” requests.

Thanks a lot in advance for your help.

Kind regards,


Hi @igorrecioh,
welcome to the community forum :tada:

The HTTP JS API supports the redirects param where you can set the maximum number of redirects to follow. You could limit the number of redirects for the first request, get the token then execute the rest of the redirects with a second request.

Here some simplified code for summary:

var response =<URL>, {redirects: 1})
var token = response.<TOKEN-PATH> 
1 Like