Postman flows not updating environment variables

Hi There,

I have recently started using postman flow. I really like the feature.
However, came across an issue related to updating environment variables and couldn’t find solution.

Problem: Request in flows not updating environment variables

Problem Description: I have multiple requests which are using environment variables and few requests are updating these environment variables so that other requests use the updated value.

I am updating environment variables as part of tests in request.

When i submit the request manually environment values are getting updated. However, when i use the same request as part of Postman Flows environment variables are not getting updated and causing following requests depended on those variables fail.

Any suggestion how to update environment variables in flows will be great help.

4 Likes

Since Postman specifically doesn’t support environment updates view Flows, your best option is to establish such variables in the flow itself. If your requests use variables, then those can still be populated/manipulated within the flow.
image

I know this issue both for old versions as for the beta version of flows.
If the intention is to “remember” the value of a variable for laters requests, I suggest to make a sequence of: send requestCreate Durables esto para la versión beta.

Yes, we can create local variables for subsequent requests. However, if we have test in the requests which are reading values from environment variables which should be updated via previous requests then those test will fail.

I have my apis inheriting the bearer token from the parent folder.

It seems like flows is not inheriting the authentication token from the folder.

I’ve tried a work around to update the environment variables through scripts in individual requests rather than within the flow itself, but it’s not working also. however it’s working if running the request itself not within the flow.

1 Like

@eng.baher77 Currently you can’t update environment variables through flows (an env is treated as read only). We plan to support writes in the future.

Welcome to the Postman community forum.

2 Likes

Thanks @Rodric-Rabbah,
Is there like a time frame for releasing this feature.

1 Like

Is there a feature request open where we can follow on development and when it will be released?
image

Hi @stijnvdnd

Welcome to the forums!

Could you tell us a little more about your use case for needing to update an Environment from the flow itself?

We don’t have a public roadmap, but we do have this as an item we want to solve in the immediate future.

I have this need as well. We have an endpoint that we use to do a cache refresh on a particular endpoint on an ISR site. But they need to specify a specific path that they want to update. So the user would set the path in the flow (via a variable or a string block or something) and we would integrate that into the body of the request. This setting of the body is actually constructed as a JWT with a signed payload so it’s done in the pre-request script. Right now, I can’t get it to use the flow-generated path.

Something similar i’m looking for. In my case i want to update the URL path variable, for this i have tried multiple ways but all works until i run the flow manually from postman but as soon as i use webhook it doesn’t work.

Things tried

  1. {{URL}}/{{localVariable}}/abc
pm.environment.set("localVariable", isValid);

This works fine for manual run but not with webhook

  1. {{URL}}/:is_valid/abc
const url = pm.request.url.toString();
const updatedUrl = url.replace('is_valid', isValid.toString());
pm.request.url.update(updatedUrl);

This works fine for manual run but not with webhook