# Can I append some data in environment variables

**URL:** <https://community.postman.com/t/can-i-append-some-data-in-environment-variables/8934>\
**Category:** Help Hub\
**Created:** [November 12, 2019, 2:54am UTC](https://community.postman.com/t/can-i-append-some-data-in-environment-variables/8934 "2019-11-12T02:54:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![surajc](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@surajc](https://community.postman.com/u/surajc)\
**Post date:** [November 12, 2019, 2:54am UTC](https://community.postman.com/t/can-i-append-some-data-in-environment-variables/8934/1 "2019-11-12T02:54:26Z")

</div>

I have a response output of a API call:

```
{
    "orgName": null,
    "roleNames": [
        "TenantDashboardOperator",
        "TenantOperator",
        "TenantSecurityAdmin",
        "TenantSuperAdmin"
    ]
}

```

When I add the output to a variable, using test script like this:

`postman.setEnvironmentVariable("TenantRoles",jsonRBData.roleNames);`

The value of TenantRoles variable gets set to the output above, but without the Double Quotes, since it becomes like an array.

Is it possible to create another variable, that has a value as the output of the roleNames, but with all quotes?

For example, for the above output, the value needs to be " “TenantDashboardOperator”, “TenantOperator”, “TenantSecurityAdmin”, “TenantSuperAdmin”. So essentially, I want to append the Double quotes and the comma to create a new variable.

The reason I am trying to do that is that the length of the array variable can be dynamic and based on the output, I need to pass this to another request like below:

```
{
   "versanms.sdwan-org-workflow":{
       "cpeDeploymentType":"SDWAN",
       "globalId": {
            orgID
         }
      },
      "ikeAuthType":"{{ikeAuthType}}",
      "orgName":"{{newOrgName}}",
      "sharedControlPlane":false,
      "supportedRoles":[
          "TenantDashboardOperator",
          "TenantOperator",
          "TenantSecurityAdmin",
          "TenantSuperAdmin"
        ]
}

```

As you can see above, I need quotes for each of the values to be passed in the request for it to pass.

Thanks,  
Suraj

---

<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 12, 2019, 9:26am UTC](https://community.postman.com/t/can-i-append-some-data-in-environment-variables/8934/2 "2019-11-12T09:26:41Z")

</div>

Hey @surajc

You would want to set the environment variable like this:

```
postman.setEnvironmentVariable("TenantRoles", JSON.stringify(jsonRBData.roleNames))

```

Or like this using the newer syntax:

```
pm.environment.set("TenantRoles", JSON.stringify(jsonRBData.roleNames))

```

To use that in a `Request Body`, you can use `{{TenantRoles}}`, without wrapping it in quotes, to add the dynamic array to your request.

---

<div class="post-metadata">

**Author:** ![surajc](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@surajc](https://community.postman.com/u/surajc)\
**Post date:** [November 12, 2019, 8:11pm UTC](https://community.postman.com/t/can-i-append-some-data-in-environment-variables/8934/3 "2019-11-12T20:11:27Z")

</div>

Ok, thanks @danny-dainton. Will try this out.

---

<div class="post-metadata">

**Author:** ![surajc](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@surajc](https://community.postman.com/u/surajc)\
**Post date:** [November 12, 2019, 8:56pm UTC](https://community.postman.com/t/can-i-append-some-data-in-environment-variables/8934/4 "2019-11-12T20:56:09Z")

</div>

> [@danny-dainton](#):
>
> pm.environment.set(“TenantRoles”, JSON.stringify(jsonRBData.roleNames))

Thanks much, @danny-dainton. This works out ok for me.
