Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
How to fetch and save multiple values as different variables in environment for postman?
{
    "Test1": {
        "label1": "Testing",
        "duration": [
            {
                "Value": "987654",
                "Ans": "True"
            },
            {
                "Value": "987159",
                "Ans": "True"
            }
        ]
    }
}

I want to fetch the value of "Value" and save them with different name in environment. Ex: "987654" saved as result1 and "987159" saved as result2 in environment.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to loop through the array of the response body and get it to save each desired item as as unique variable. Based on your requiremments it would be:

var jsonData = pm.response.json();
for (let i = 0; i < jsonData.Test1.duration.length; i++) {
    pm.environment.set(
        "result" + [i+1], jsonData.Test1.duration[i].Value
    )
}

The first block in an array is actually an object value of 0, hence in the function above the loop has to stat with i = 0, however as you wanted the variable to start with integer '1' for the first value required, the name is set as "result" + [i+1] to ensure they are saved with result(n), starting with 'result1' onwards

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!