# Referencing environment variable from collection variable

**URL:** <https://community.postman.com/t/referencing-environment-variable-from-collection-variable/71012>\
**Category:** Help Hub\
**Tags:** variables, collections\
**Created:** [November 8, 2024, 4:20pm UTC](https://community.postman.com/t/referencing-environment-variable-from-collection-variable/71012 "2024-11-08T16:20:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwisnicki](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/mwisnicki/32/30664_2.png) [@mwisnicki](https://community.postman.com/u/mwisnicki)\
**Post date:** [November 8, 2024, 4:20pm UTC](https://community.postman.com/t/referencing-environment-variable-from-collection-variable/71012/1 "2024-11-08T16:20:30Z")

</div>

I have a collection per service and environments for Dev and Prod

At the environment level I would like to set variable like this:

```auto
apiBaseUrl = https://api-dev.example.com

```

and then in the collection `service1` I would like variable like so:

```auto
baseUrl = {{apiBaseUrl}}/service1

```

Unortunately when I reference `{{baseUrl}}` in a query inside `service1` it’s value is expanded to `{{apiBaseUrl}}/service1`.

Is Postman incapable of recursive variable expansion?

---

<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:** [November 8, 2024, 4:30pm UTC](https://community.postman.com/t/referencing-environment-variable-from-collection-variable/71012/2 "2024-11-08T16:30:30Z")

</div>

Hey @mwisnicki 👋

Welcome to the Postman Community! :postman:

Are you able to share an image of how that looks in your Postman instance, please?

To resolve the variable value you would need to use the `.replaceIn('{{var_name}}')` function. As everything that’s stored in the environment file is a string, without resolving it correctly, you’re just going to get that string value back.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 8, 2024, 4:31pm UTC](https://community.postman.com/t/referencing-environment-variable-from-collection-variable/71012/3 "2024-12-08T16:31:08Z")

</div>

Closed on December 8, 2024, 4:31pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
