Is there a way to retrieve a URL with environment variables resolved?

We have a ton of requests and all of them have the same format. All of them contain environment variables but its a pain when you want to send the URL of a request to someone else because you have to manually replace all the variables with values from the selected environment.

Is there a way to easily copy the URL of a request with environment variables resolved based on the currently selected environment?

Could you send them a curl request using the code snippets? If the environment is selected it will show the resolved variables.

If you’re working in a Team Workspace, you could also share the environment to that workspace for them to use. They would have the environment file so the variables would be resolved when it’s active.

2 Likes

I dont have to send them the whole curl. I can just copy the resolved URL from there and send it to them. This works. I’d like a button for this in the textbox of the URL but this does work better than having to fabricate it manually.

It is already a shared workspace but they dont use postman.

console.log(pm.variables.replaceIn(pm.request.url.toString()))

add this to your pre-request script and now you can copy the resolved url from postman console

Hi @praveendvd,

In this case, we might need to actually trigger the request to see the output in postman console.

1 Like

Where do I actually find the console this will be written to?

1 Like

image

on the bottom left corner or view>show postman console (alt+ctrl+c)

sorry yes my mistake :smiley: then you could simply copy the resolved url from the request :smiley:

in console you can copy the resolved request as it is don’t need to print it as @darkphoenix mentioned , :smiley:

Yes and as @dannydainton mentioned copying from curl is the best way to extract the request url, I believe. :slight_smile:

1 Like

Yes. The console already shows the resolved URLS for all requests executed. That is neat.

I’ve submitted an issue at the github to make it easier to get the resolved URL by maybe a button in the url textbox. That would be allot easier.

Thanks you guys.

yes in all code snippets the variables are shown after resolving

1 Like