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

188
Vistas
Postman script execution before mockup server response

I am running mock server in Postman which basically sends responses on specific requests. Both response and requests contain Environmental variables of String type which should be unique and I change them before each request to my mock server which is quite annoying.

I would like to have these variables updated by pre-request script before I receive response. I have seen similar question here, but it doesn't work for me — I have tried putting script below to Tests tab to the Request I am mocking response for, but it is not executed.

    function makeid(length) {
        var result           = '';
        var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        var charactersLength = characters.length;
        for ( var i = 0; i < length; i++ ) {
          result += characters.charAt(Math.floor(Math.random() * 
     charactersLength));
       }
       return result;
    }

     pm.environment.set("unique_id", makeid(7));
     pm.environment.set("payment_id", makeid(10));

Please tell if Postman is able at all to execute scripts before sending responses from its Mock server or it is not possible? If it is not able to do so, then are there any ways to automatically update variables before each request?

about 4 years ago · Juan Pablo Isaza
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