Hi.
I have a pre-request script that is generating a JWT auth token. Variables are taken from globals variable pool.
When I change workspace very often those variable are unreadable, and therefore undefined.
To solve that I need to edit global envs and just save the changes without any changes.
Hi Danny.
I’m not sure I follow.
So I have Variable A in workspace 1, but when I switch to workspace 2 and back to 1 I won’t be able to access that anymore?
I don’t have problem with variable per environment so I’m sure that when I move this will variable down this will work, but then the point of having this var globally for all envs is gone, right?
Those variables are not globally accessible across all workspaces.
If the Global variable is available in the workspace where you’re accessing it using pm.globals.get('var_name') then it should be resolved correctly but if it’s not part of that Workspace, it would be undefined.
All the Global variables for a Workspace, are only available within that Workspace.
That’s clear. But I am in the workspace in which I have environments dev/stage/prod and all those are sharing the same global variable: serviceAuthBaseUrl.
The problem is, that very often when I switch between workspaces this variable is undefined. I have to enter the edition screen and overwrite the value for it to be seen by pre-request script.
Seems like it stopped working for me as well.
Even more it stopped overriding global variables with environment ones.
I have pre request script with pm.globals.get(“url”).
I logged url in that script and was undefined.
Then I changed environment (diferent url) and it logged GLOBAL value.
So it is related to what thread owner said.
The workspace is about half a year old so it worked before.
I have the same problem. Variables with scope “collection variables” or “global” are not saved or updated when changed in Pre-request scripts. Probably a bug
If this is for me, as it’s been a while and there are very few examples on the thread of what is going on, it’s going to be difficult to have any input on this topic.
Are you facing a similar problem? Can you provide examples or a short recording of the issue you’re facing in the latest version?
i think i resolved the issue.
from pm.globals.get('apiKeyTest') to pm.environment.get('apiKeyTest')
not sure this is exactly the issue you guys encountered. but i think it is similar from the issue i have encountered.