Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda