Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda