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

289
Vistas
How to retrieve global varibles configured on the request url in the pre-request script

I am preparing a postman sample that uses some global variables in the url parameters.

enter image description here

The valibles {{api-url}} and {{public-address}} are defined under Globals.

enter image description here

I also have a script in Pre-request Script where it tries to retrieve the request url.

var url = pm.request.url
console.log("URL=" + url)

However when I run this I do not get the url with the global variables filled in. Instead I get the below;

enter image description here

For the request itself I get the varibales filled in , I had to mask them due to privacy reasons.

I believe at the time of the Pre-reuest script the request url may not have filled with global variables? If so how can I get these valies in the url?

I definitely can re construct the URL in the Pre-request script itsef, but then that would duplicate things ...

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It appears that the actual request is resolving those values in the UI. If you're just needing to resolve the same in the log output, it would be like this:

let url = pm.request.url
console.log("URL=" + pm.variables.replaceIn(url))

As the log statement is just a string value of the UI, the variables are displayed as they are in the request URL. You would need to use replaceIn() to substitute those for the resolved values.

https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object

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