Is there a way to retrieve the redirected url from a Postman response?
Asked Answered
F

1

11

I'm trying to submit a form in Postman which then redirects to another url. The redirected url query string contains some information that I want to use in my next call. Is this even possible and if yes, how?

I haven't been able to find anything in Postman docs regarding this.

Frustration answered 25/6, 2019 at 22:56 Comment(0)
C
15

Yes, you can retrieve the redirected URL, extract interested information, and use it in the next request in Postman.

First, to retrieve the redirected URL, the "Automatically follow redirects" option in Postman should be turned off:

enter image description here

Then, you can intercept the redirect response, extract what is interested, and set it as global variable or environment variable:

enter image description here

Finally, this variable can be used in "next request", as query string in GET request, or as part of POST request's body:

enter image description here

enter image description here

Couching answered 26/6, 2019 at 0:38 Comment(3)
Thanks! Do you know if there is a way to programatically set the "Automatically follow redirects" option? It's just that I have to share my collection with the team and not everyone will have the same settings.Frustration
I take a look at Postman's API reference (learning.getpostman.com/docs/postman/scripts/…), but unfortunately, can't find anything to program "Automatically follow redirects" option :(Couching
--ignore-redirects Prevents newman from automatically following 3XX redirect responses. github.com/postmanlabs/newman#newman-optionsLess

© 2022 - 2024 — McMap. All rights reserved.