I am trying to create a request to initialize an environment variable to be used in other requests. The value of this environment variable can be one of five possible values.
To do so, I use a pre-request script that reads the value of the query parameter (thisValue) and sets the environment variable (chosenValue) with that value.
// Set the chosenValue environment variable with this value
pm.environment.set('chosenValue', pm.request.url.query.get('thisValue'));
Next, I made additional query params in the same request, each using the same key. Each instance of the param was set with one of the five possible values.
My expectation was that I could activate one of these five query params and those deactivated would be ignored, sending the value of the active query param to the environment variable via the pre-request script.
Instead, the activated param is used in the request url, but no matter which instance of the query parameter is checked as active, the pre-request script always uses the value of the param at the bottom of the list.
I realize this may be somewhat of a hack, but is there a way of accomplishing this or something similar? I have looked through other threads about being able to select environment variables quickly from a list, but have not seen a solution that seemed to apply.
Perhaps this is simply not possible or best practice. In any case, I appreciate any feedback.
Platform Details:
- Postman for Windows v10.19.17
- UI version 10.19.17-ui-231106-0450
- Desktop platform version 10.19.7
- Architecture x64
- OS platform win32 10.0.19045