How to use Environments

I read a few pages on how to use environments and I get it.

The issue I’m having is that when I parameterize a HTTPS URL, it doesn’t work but HTTP does.

I check my settings and they appear to be correct.

If anyone has any advice, I’d appreciate it.

Hey @sickmetal,

Are you able to post some screenshots (masking any sensitive details) or some examples to show what’s happening.

Hopefully this screenshot helps:

Did you add that value to the token to mask the actual token?

If not, I’m not sure why that’s in there :grin:

The token needs to be changed every hour and that token was valid early this morning :slight_smile:

That looks like a URL to get a token rather than an actual token.

I might be missing something here but that doesnt like quite right to me.

I would expect the details within that URL to be added to a form to get the token and then it would return with a different value.

The URL has a token to authenticate itself with our system. The Account ID at the end of the URL tells the system what account information to pull. I’m new to this company and this is how API testing is performed.

If I remove the environment {{url}} and use “https://…” then the API can be reached and it returns a Status code and result set.

What’s saved in the {{url}} variable? If that’s the same as the hardcoded version, it should be working.

Are you about to show more images of the environment file and the headers please.

I’m sure this is something simple that we can sort out together. :slight_smile:

The hardcoded version and {{url}} are exactly the same.

I assume you wanted to see the following image: (let me know if you need something else)

I appreciate your help in trying to get this resolved!!

There’s 2 slightly different values in that image.

The current is missing the www- in the URL. This is the value that would get used for the request being sent so it might be the reason it’s failing.

1 Like

WOW…I can’t believe I didn’t catch that! I think that I initially typed in the Initial Value, pressed tab and saw the Current value updated, I must have changed it accidentally

1 Like

These things happen :slight_smile: - Is it all working for you now with the variable set?

I think I’m good for now, Thx again for all of your help!!!:smile:

1 Like

Hi I have one query related to environment variable

How to fetch initial value from environment variables

When we dont have current value


Hi @joginder8788 -

From the docs:

you can leave the current value field empty and the old behavior of Postman will take precedence wherein your initial value would be treated as your current value.

And the standard way to fetch variables is by…

  1. using double curly braces like {{variable-name}} in the text sections, or
  2. using Javascript like pm.environment.get("variable-name") in the pre-request and test script tabs

Hi joyce,

When we call it using Javascript like pm.environment.get("variable-name"), it’s not working when current value is blank, it only fetches current value

Hi Joyce,

COuld you please get back to me on Env Issue

@joginder8788 -
The Postman app copies the initial value over to the current value while creating a new variable. If you then delete the current value, there’s no API access to the initial values. This allows users to test with an empty variable.

If API access to the initial values is something that you’re looking for, submit a feature request, and be sure to provide more context for your specific use case.