I am migrating from Postman to Apidog and am encountering issues with getting the global team variables to function correctly.
pm.globals.get(‘DYNAMIC_EMAIL’, ‘TEAM’); // Shows the initial value set in the resources window
pm.globals.set(“DYNAMIC_EMAIL”, ‘[email protected]’, ‘TEAM’); // Overwrites the variable within the script but nowhere else
The next time I call pm.globals.get(‘DYNAMIC_EMAIL’, ‘TEAM’); from a different script, the value reverts to the initial value set in the dashboard rather than the one I intended to overwrite from the pre-processor or post-processor.
I absolutely need to be able to save the values using JavaScript in the pre and post-processing scripts. Is there something I am missing to ensure that the variables are properly saved to the team global space so that my teammates will see the same value across all project spaces when they return to use the APIs?
Edit:
I would also like to add that I have used the variable extractor to test this as well.
I have the variables all named and set in the ENV/GLOBAL/TEAM space and I am able to extract the variables to the ENV and GLOBAL space but they will never save to the team space.
Sounds like we were mid upgrade process and something was hanging between the upgrade. After a day and several login/logout’s the functionality started working.
I appreciate the reply but the change log doesn’t really provide any useful information about the team variables. I have gone through the docs and followed the information laid out there but I am not able to get the global team variables set from a pre or post script. I was mistaken about them updating in my last post.
Can you confirm if team variables are able to be set from a pre or post script?
This functionality is extremely important to us and may steer us away from Apidog if we are unable to do this. We would be losing all out automated functionality if we can’t set dynamic variables to be shared across projects.
Just to be clear I have read that document and it suggests that I am able to set those variables from the pre and post processors like so:
Global variables shared within the team:
// Set a team-shared global variable
pm.globals.set('variable_key', 'variable_value', 'TEAM');
// Unset a team-shared global variable
pm.globals.unset('variable_key', 'TEAM');