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

101
Views
Saving response to environment with multiple values

I'm trying to save these IDs, but they are not getting saved to my environment variables and I'm seeing the console output as:

undefined
undefined

Json Response

{
    "savedIds": [
        95672,
        95673
    ]
}

Test

for(let i = 0; i< jsonData.savedIds.length; i++) {
pm.environment.set("savedID" + [i+1],jsonData)
console.log(pm.environment.get('savedIds' + [i+1]));
};
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Firstly, your code to get JSON data works well such as written here:

let jsonData = {
    "savedIds": [
        95672,
        95673
    ]
};

for(let i = 0; i < jsonData.savedIds.length; i++) {
  console.log(i + ", " + jsonData.savedIds[i]);
};

The issue come from the key used with Postman. You are using savedID then savedIds. So, you will do something like this:

for(let i = 0; i< jsonData.savedIds.length; i++) {
  pm.environment.set("savedID" + [i+1], jsonData.savedIds[i])
  console.log(pm.environment.get('savedID' + [i+1]));
};
about 4 years ago · Juan Pablo Isaza Report

0

Just as an alternative way of doing the same thing:

jsonData.savedIds.forEach((id, index) => pm.environment.set(`savedID_${index + 1}`, id));

or using Lodash in Postman:

_.each(jsonData.savedIds, (id, index) => pm.environment.set(`savedID_${index + 1}`, id));
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!