# How to capture a query parameter from a redirect URL after a POST request?

**URL:** <https://community.postman.com/t/how-to-capture-a-query-parameter-from-a-redirect-url-after-a-post-request/81711>\
**Category:** Help Hub\
**Tags:** newman-project, authentication, json, redirect, postman-flows\
**Created:** [June 30, 2025, 1:48pm UTC](https://community.postman.com/t/how-to-capture-a-query-parameter-from-a-redirect-url-after-a-post-request/81711 "2025-06-30T13:48:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacecraft-explore14](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@spacecraft-explore14](https://community.postman.com/u/spacecraft-explore14)\
**Post date:** [June 30, 2025, 1:48pm UTC](https://community.postman.com/t/how-to-capture-a-query-parameter-from-a-redirect-url-after-a-post-request/81711/1 "2025-06-30T13:48:01Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

I’m working with an OAuth-like flow where I:

1. Send a `POST` request to `/authorise/authenticate` with credentials.
2. That request responds with a `302` redirect to a `GET` URL like:  
`https://example.com/?code=abc123&state=xyz`

I’m running this as part of a Postman collection (potentially via Newman later), and I need to **extract the `code` parameter from that redirected GET URL**.

But I’ve found that Postman:

- Follows redirects automatically
- Does not expose the final redirected URL in the response object
- Doesn’t allow me to access it in scripts (pre-request/test)

**Is there any way (via scripting, settings, or workarounds) to catch that `code` from the redirect URL inside Postman?**  
Just in case - the ultimate goal is to make this collection run fully headless (no UI interaction) so we can integrate it into our CI/CD pipeline using Newman.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [June 30, 2025, 4:36pm UTC](https://community.postman.com/t/how-to-capture-a-query-parameter-from-a-redirect-url-after-a-post-request/81711/2 "2025-06-30T16:36:12Z")

</div>

How about if you go into your Postman settings and disable “Automatically follow redirects” in the general tab under headers.

Also this topic might be of use.

[Pre-request script to automate authorization code grant type - Ask the Experts and Postman Tips - Postman Community](https://community.postman.com/t/pre-request-script-to-automate-authorization-code-grant-type/45989/13)

---

<div class="post-metadata">

**Author:** ![spacecraft-explore14](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@spacecraft-explore14](https://community.postman.com/u/spacecraft-explore14)\
**Post date:** [July 1, 2025, 8:15am UTC](https://community.postman.com/t/how-to-capture-a-query-parameter-from-a-redirect-url-after-a-post-request/81711/3 "2025-07-01T08:15:15Z")

</div>

> [@michaelderekjones](#):
>
> Pre-request script to automate authorization code grant type - Ask the Experts and Postman Tips - Postman Community

Thank you so much!  
It helped!
