Asynchronous request using environment variables

I’m trying to prep a user with data needed before the test runs and so in my pre-request script I post data to an endpoint.

We have 3 different test environments where the endpoint is slightly different, e.g. https://localhost:1234/v1/update and, and because of this we have parameterised the service names and used them in our postman requests. They look something like this:

country: gb
domain: stg
api_environment: https://eu3-1.{{country}}.{{domain}}.io:83
user_service: {{api_environment}}/user

However I cannot use them in my asynchronous request as using pm.environment.get(“user_service”) + ‘/v1/update’ returns {{api_environment}}/user/v1/update which obviously fails as not a proper url.

Is there a way in postman to translate these variables so that the fully formed url is returned? Currently I am assuming that this is not possible and I’ll have to add a request beforehand just to set up the data.

@Meerkatjie You can use pm.environment.get('var_name') instead of {{var_name}}, which will achieve the desired effect :smile: