Support to export Environment variables through javascript

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.

Hey @shid19nov :wave:

Welcome to the Postman Community! :postman:

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

There isn’t a way to export environment a file through the sandbox (Like the manual export), you could use the Postman API 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.

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

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

{
  "_": {
    "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"
}