This scenario used to work in a previous version of Postman this year:
- call
postman.setGlobalVariable('test', 'my_value')in a pre-request script - let the pre-request script finish by throwing an Error (this is required because I have to validate the environment variables)
- after the Postman request is executed (with the Error thrown in pre-request script) the global variable
testwith valuemy_valueis available in the Globals list.
In the current (5.2.1) version of Postman the global variables are not persisted from a pre-request script that throws an Error.
- Is there a way to enable this?
- Is there a way to work around this?
My use case is implementing a guard for DELETE REST calls to avoid unintentional deletion of server-side objects. The user had to send the same request (press Send) a given amount of times in order to make sure he really wants to execute this request. This was achieved and worked until recently using global variables.