Skip to content

Get redirected URL from Postman

I’m currently migrating my old website to a new one and I have just created some url redirect rules to redirect old links to their pages on the new website.

In order to test these redirect rules I’m using Postman but I can’t find any way of getting the redirected url from Postman’s scripts documentation. REDIRECTED_URL is the url after being processed by the redirect rule.

Here is my current test:

var root_url = postman.getEnvironmentVariable('root_url');
var oldurl = root_url + postman.getEnvironmentVariable('old_page');
var newurl = root_url + postman.getEnvironmentVariable('new_page');
if (REDIRECTED_URL == newurl)
    tests[oldurl + " redirected"] = true;
    tests[oldurl + " failed to redirect"] = false;

Is there a way to test this in postman or should I be using another application?


  1. Switch off the setting Automatically follow redirects in Postman.
  2. Do a request to
  3. In the test tab, check if the https status code and the re-direct header are correct:
pm.test("Status Code is 301", function () {;
pm.test("Location-header exists", function () {