# How to use Environments

**URL:** <https://community.postman.com/t/how-to-use-environments/5153>\
**Category:** Help Hub\
**Created:** [April 25, 2019, 4:20pm UTC](https://community.postman.com/t/how-to-use-environments/5153 "2019-04-25T16:20:30Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 25, 2019, 4:20pm UTC](https://community.postman.com/t/how-to-use-environments/5153/1 "2019-04-25T16:20:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 25, 2019, 5:24pm UTC](https://community.postman.com/t/how-to-use-environments/5153/2 "2019-04-25T17:24:54Z")

</div>

Hey @sickmetal,

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

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 25, 2019, 7:30pm UTC](https://community.postman.com/t/how-to-use-environments/5153/3 "2019-04-25T19:30:45Z")

</div>

Hopefully this screenshot helps:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/c/ccf92c25c8cd821de62d8a8d9445bbf9139bd22e.png)

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 25, 2019, 7:34pm UTC](https://community.postman.com/t/how-to-use-environments/5153/4 "2019-04-25T19:34:50Z")

</div>

![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/4/34142830eeb1b7a42c196065abc0a4805b90472c.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 25, 2019, 8:02pm UTC](https://community.postman.com/t/how-to-use-environments/5153/5 "2019-04-25T20:02:31Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 25, 2019, 8:09pm UTC](https://community.postman.com/t/how-to-use-environments/5153/6 "2019-04-25T20:09:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 25, 2019, 8:21pm UTC](https://community.postman.com/t/how-to-use-environments/5153/7 "2019-04-25T20:21:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 25, 2019, 9:09pm UTC](https://community.postman.com/t/how-to-use-environments/5153/8 "2019-04-25T21:09:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 26, 2019, 12:59pm UTC](https://community.postman.com/t/how-to-use-environments/5153/9 "2019-04-26T12:59:51Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 26, 2019, 2:48pm UTC](https://community.postman.com/t/how-to-use-environments/5153/10 "2019-04-26T14:48:48Z")

</div>

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)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/0/a0ed8a4333bf346248be32e317f31f70b12d4c06.png)

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

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 26, 2019, 2:51pm UTC](https://community.postman.com/t/how-to-use-environments/5153/11 "2019-04-26T14:51:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 29, 2019, 3:46pm UTC](https://community.postman.com/t/how-to-use-environments/5153/12 "2019-04-29T15:46:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 29, 2019, 3:48pm UTC](https://community.postman.com/t/how-to-use-environments/5153/13 "2019-04-29T15:48:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sickmetal](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sickmetal](https://community.postman.com/u/sickmetal)\
**Post date:** [April 29, 2019, 4:04pm UTC](https://community.postman.com/t/how-to-use-environments/5153/14 "2019-04-29T16:04:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joginder8788](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@joginder8788](https://community.postman.com/u/joginder8788)\
**Post date:** [June 24, 2019, 8:28am UTC](https://community.postman.com/t/how-to-use-environments/5153/15 "2019-06-24T08:28:53Z")

</div>

Hi I have one query related to environment variable

How to fetch initial value from environment variables

When we dont have current value

![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/0/80e672460119af8218a99283a66e92e15f01dfbf.png)

---

<div class="post-metadata">

**Author:** ![jetison](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jetison/32/12_2.png) [@jetison](https://community.postman.com/u/jetison)\
**Post date:** [June 24, 2019, 5:56pm UTC](https://community.postman.com/t/how-to-use-environments/5153/16 "2019-06-24T17:56:30Z")

</div>

Hi @joginder8788 -

From the [docs](https://learning.getpostman.com/docs/postman/environments_and_globals/sessions#editing-collection-variables):

> 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

---

<div class="post-metadata">

**Author:** ![joginder8788](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@joginder8788](https://community.postman.com/u/joginder8788)\
**Post date:** [June 25, 2019, 7:25am UTC](https://community.postman.com/t/how-to-use-environments/5153/17 "2019-06-25T07:25:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joginder8788](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@joginder8788](https://community.postman.com/u/joginder8788)\
**Post date:** [July 1, 2019, 5:52am UTC](https://community.postman.com/t/how-to-use-environments/5153/18 "2019-07-01T05:52:39Z")

</div>

Hi Joyce,

COuld you please get back to me on Env Issue

---

<div class="post-metadata">

**Author:** ![jetison](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jetison/32/12_2.png) [@jetison](https://community.postman.com/u/jetison)\
**Post date:** [July 1, 2019, 4:20pm UTC](https://community.postman.com/t/how-to-use-environments/5153/19 "2019-07-01T16:20:26Z")

</div>

@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](https://github.com/postmanlabs/postman-app-support/labels/feature), and be sure to provide more context for your specific use case.
