# Support to export Environment variables through javascript

**URL:** <https://community.postman.com/t/support-to-export-environment-variables-through-javascript/60183>\
**Category:** Help Hub\
**Tags:** tests, variables, environments, scripts\
**Created:** [April 22, 2024, 3:22am UTC](https://community.postman.com/t/support-to-export-environment-variables-through-javascript/60183 "2024-04-22T03:22:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shid19nov](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@shid19nov](https://community.postman.com/u/shid19nov)\
**Post date:** [April 22, 2024, 3:22am UTC](https://community.postman.com/t/support-to-export-environment-variables-through-javascript/60183/1 "2024-04-22T03:22:33Z")

</div>

Currently we can export the environment data using manual intervention, do we have any way by which we can export the environment variables using java script code under test tab.

Use case:  
Need to compare API response data , Both API url are same but the response key are different. V1 (OLD API) data need to be compare with V2 (New) API.  
Collection will be run through NEWMAN , so there is limited support in NEWMAN for export data. Currently newman is exporting complete data except Environment variables data.

---

<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 22, 2024, 9:29am UTC](https://community.postman.com/t/support-to-export-environment-variables-through-javascript/60183/2 "2024-04-22T09:29:41Z")

</div>

Hey @shid19nov 👋

Welcome to the Postman Community! :postman:

You can use the following flag in Newman to export the variables at the end of the run:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/9/89e6e33bdaf3142699fded9cbf3287927bc7e7c5.png)

There isn’t a way to _export_ environment a file through the sandbox (Like the manual export), you could use the [Postman API](https://www.postman.com/postman/workspace/postman-public-workspace/request/12959542-0ed17eac-d49f-4881-bbfe-bdc0282f50c6?action=share&source=copy-link&creator=1794236) to get the currently sync’d variables from an environment.

You could also add the data you want to compare to a data file and run that with the Collection Runner to validate the response values.

> **[Run collections using imported data | Postman Learning Center](https://learning.postman.com/docs/collections/running-collections/working-with-data-files/)**
>
> Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.

I would need to know more details about the intended workflow to off more options.

---

<div class="post-metadata">

**Author:** ![shid19nov](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@shid19nov](https://community.postman.com/u/shid19nov)\
**Post date:** [April 25, 2024, 6:31am UTC](https://community.postman.com/t/support-to-export-environment-variables-through-javascript/60183/3 "2024-04-25T06:31:42Z")

</div>

Scenario : From one collection - i exported the environment variables using newman export option in JSOn format  
Now i want to use the same file in second collection , while importing the exported JSON , we have error for the format “The JSON must be an array”.  
As i know the imported format should be an array. But the newman exported format is not as per postman import format.

Also i have tried with CSV as well. Same error for format.

My case : I want to use the exported environment file as it is in next collection .

Sample exported file

```auto
{
  "_": {
    "postman_variable_scope": "environment",
    "postman_exported_at": "2024-03-08T06:53:19.367Z",
    "postman_exported_using": "Postman/10.23.1"
  },
  "id": "51b84b59-9eda-4c22-ae58-1220a0d55ed3",
  "name": "NewLoanEnvironment",
  "values": [
    {
      "type": "any",
      "value": "",
      "key": "mobile_number"
    },
    {
      "type": "any",
      "value": "",
      "key": "email"
    },
    {
      "type": "any",
      "value": "",
      "key": "access_token"
    },
    {
      "type": "any",
      "value": "bearer",
      "key": "token_type"
    },
    {
      "type": "any",
      "value": 1268,
      "key": "company_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "user_id"
    },
    {
      "type": "any",
      "value": "2023-04-25",
      "key": "employment_start_date"
    },
    {
      "type": "any",
      "value": "2006-04-25",
      "key": "birth_date"
    },
    {
      "type": "any",
      "value": "",
      "key": "anonymous_id"
    },
    {
      "type": "any",
      "value": ,
      "key": "gross_income"
    },
    {
      "type": "any",
      "value": "",
      "key": "net_income"
    },
    {
      "type": "any",
      "value": "3",
      "key": "no_of_dependents"
    },
    {
      "type": "any",
      "value":,
      "key": "loan_amount"
    },
    {
      "type": "any",
      "value": 3,
      "key": "loan_tenure"
    },
    {
      "type": "any",
      "value": "",
      "key": "reference_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "application_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "emergency_mobile_number"
    },
    {
      "type": "any",
      "value": "",
      "key": "maxLoanAmount"
    },
    {
      "type": "any",
      "value": ",
      "key": "country_code"
    },
    {
      "type": "any",
      "value": "3",
      "key": "minLoanTenure"
    },
    {
      "type": "any",
      "value": "",
      "key": "iterationCount"
    },
    {
      "type": "any",
      "value": "",
      "key": "env"
    },
    {
      "type": "any",
      "value": "",
      "key": "maritalStatus_temp"
    },
    {
      "type": "any",
      "value": ,
      "key": "loan_purpose_master"
    },
    {
      "type": "any",
      "value": ,
      "key": "refresh_token"
    },
    {
      "type": "any",
      "value": "",
      "key": "loan_purpose"
    },
    {
      "type": "any",
      "value": "",
      "key": "Marital Status"
    },
    {
      "type": "any",
      "value": "17909.86",
      "key": "amount_to_disbursed"
    },
    {
      "type": "any",
      "value": "2024-07-28",
      "key": "maturity_date"
    },
    {
      "type": "any",
      "value": "",
      "key": "Bulk Reference id0"
    },
    {
      "type": "any",
      "value": "3257842",
      "key": "customer_verification_document_id"
    },
    {
      "type": "any",
      "value": ,
      "key": "presigned_url_temp"
    },
    {
      "type": "any",
      "value": "8494033203",
      "key": "randomNumer"
    },
    {
      "type": "any",
      "value": "C8c7uqi7qX",
      "key": "randomString_2"
    },
    {
      "type": "any",
      "value": "",
      "key": "govt_id_document_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "company_id_front_document_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "company_id_back_document_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "payslip_1_document_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "payslip_2_document_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "COMPANY_SPECIFIC_DOC_2_document_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "Max_Loan_Amount"
    },
    {
      "type": "any",
      "value": "",
      "key": "Max_Loan_Tenure"
    },
    {
      "type": "any",
      "value": "",
      "key": "employment_type_master"
    },
    {
      "type": "any",
      "value": "OTHERS",
      "key": "employment_type"
    },
    {
      "type": "any",
      "value": "",
      "key": "risk_simulation_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "offer_loan_amount"
    },
    {
      "type": "any",
      "value": "",
      "key": "offer_loan_tenure"
    },
    {
      "type": "any",
      "value": "",
      "key": "simulation_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "New_Service_Loan_Offer"
    },
    {
      "type": "any",
      "value": 10216,
      "key": "env_flow_state_id"
    },
    {
      "type": "any",
      "value": "2024-04-25T11:55:49+05:30",
      "key": "date_time"
    },
    {
      "type": "any",
      "value": "",
      "key": "COMPANY_SPECIFIC_DOC_1_document_id"
    },
    {
      "type": "any",
      "value": "YES",
      "key": "COE_Doc Required"
    },
    {
      "type": "any",
      "value": "",
      "key": "EIR"
    },
    {
      "type": "any",
      "value": "POST_GRADUATE",
      "key": "educational_level"
    },
    {
      "type": "any",
      "value": "SUPERVISOR_OR_TEAM_LEAD",
      "key": "job_level"
    },
    {
      "type": "any",
      "value": ,
      "key": "token"
    },
    {
      "type": "any",
      "value": 19464.71,
      "key": "principal_amount"
    },
    {
      "type": "any",
      "value": 3463.1,
      "key": "payment_per_cutoff"
    },
    {
      "type": "any",
      "value": "804745",
      "key": "userid"
    },
    {
      "type": "any",
      "value": "",
      "key": "id"
    },
    {
      "type": "any",
      "value": "",
      "key": "product_type"
    },
    {
      "type": "any",
      "value": "",
      "key": "sub_product_type"
    },
    {
      "type": "any",
      "value": "",
      "key": "status"
    },
    {
      "type": "any",
      "value":,
      "key": "SUPPORTING_DOC_2"
    },
    {
      "type": "any",
      "value":,
      "key": "SUPPORTING_DOC_1"
    },
    {
      "type": "any",
      "value":,
      "key": "payslip_id_two"
    },
    {
      "type": "any",
      "value":,
      "key": "payslip_doc_id_2"
    },
    {
      "type": "any",
      "value":,
      "key": "payslip_id_one"
    },
    {
      "type": "any",
      "value":,
      "key": "payslip_doc_id_1"
    },
    {
      "type": "any",
      "value":,
      "key": "company_id_two"
    },
    {
      "type": "any",
      "value":,
      "key": "company_id_one"
    },
    {
      "type": "any",
      "value":,
      "key": "Govt_Id_number"
    },
    {
      "type": "any",
      "value":,
      "key": "selfie_id"
    },
    {
      "type": "any",
      "value": "",
      "key": "employee_id"
    },
    {
      "type": "any",
      "value": "-Ted",
      "key": "first_name"
    },
    {
      "type": "any",
      "value": "",
      "key": "last_name"
    },
    {
      "type": "any",
      "value": "I",
      "key": "middle_name"
    },
    {
      "type": "any",
      "value": "",
      "key": "employment_status"
    },
    {
      "type": "any",
      "value": "2023-04-25",
      "key": "joining_date"
    },
    {
      "type": "any",
      "value": 9894.56,
      "key": "salary_gross_1"
    },
    {
      "type": "any",
      "value": 9894.56,
      "key": "salary_gross_2"
    },
    {
      "type": "any",
      "value": 19789.12,
      "key": "salary_gross"
    },
    {
      "type": "any",
      "value": "Butuan",
      "key": "cur_city"
    },
    {
      "type": "any",
      "value": "",
      "key": "cur_province"
    },
    {
      "type": "any",
      "value": "CURRENT",
      "key": "cur_tag"
    },
    {
      "type": "any",
      "value": "5508 Grady Common",
      "key": "cur_street_block_house_number"
    },
    {
      "type": "any",
      "value": "4444",
      "key": "cur_zip_code"
    },
    {
      "type": "any",
      "value": "Butuan",
      "key": "per_city"
    },
    {
      "type": "any",
      "value": "Agusan Del Norte",
      "key": "per_province"
    },
    {
      "type": "any",
      "value": "PERMANENT",
      "key": "per_tag"
    },
    {
      "type": "any",
      "value": "9078 Moen Way",
      "key": "per_street_block_house_number"
    },
    {
      "type": "any",
      "value": "4444",
      "key": "per_zip_code"
    },
    {
      "type": "any",
      "value": "",
      "key": "Borrower_email"
    },
    {
      "type": "any",
      "value":,
      "key": "TaxableIncome"
    },
    {
      "type": "any",
      "value": "0.00",
      "key": "WTAX"
    },
    {
      "type": "any",
      "value": "",
      "key": "Net_salary"
    },
    {
      "type": "any",
      "value": "",
      "key": "company_url"
    },
    {
      "type": "any",
      "value": null,
      "key": "COE_DOC"
    },
    {
      "type": "any",
      "value": "",
      "key": "employee_object_id"
    },
    {
      "type": "any",
      "value": 19464.71,
      "key": "new_principal_amount"
    },
    {
      "type": "any",
      "value": 3,
      "key": "new_loan_tenure"
    },
    {
      "type": "any",
      "value": 3463.1,
      "key": "new_payment_per_cutoff"
    },
    {
      "type": "any",
      "value": 0,
      "key": "PBA"
    },
    {
      "type": "any",
      "value": "",
      "key": "product_id"
    },
    {
      "type": "any",
      "value": ,
      "key": "disbursement_id"
    },
    {
      "type": "any",
      "value":,
      "key": "disbursement_amount"
    }
  ],
  "_postman_variable_scope": "environment",
  "_postman_exported_at": "2024-04-25T06:26:31.161Z",
  "_postman_exported_using": "Newman/6.1.2"
}

```

---

<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:** [May 25, 2024, 6:32am UTC](https://community.postman.com/t/support-to-export-environment-variables-through-javascript/60183/4 "2024-05-25T06:32:12Z")

</div>

Closed on May 25, 2024, 6:32am UTC

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