Hi
I am using a legacy API that following authentication via a login API returns a session id in plain text in the response body that is needed to authenticate subsequent API calls . I have been searching and trying for two days to find a way to set this value into a “session-id” environment variable without success. Have found loads of examples of JSON and nested values but no idea how to set it using the response body which is 69 characters but with no markup. I am not a developer and really struggling so any help appreciated.
I have tried the following but no idea what to put for the “variable_value”
Would you be able to post an example of the response and what value you would like to set please?
To get the response in text form, you can use pm.response.text(), depending on what part you would like to store, you can use basic JS to cut this down to the required value.
If the response is in the form you need already, you just need to add this to the Tests tab to capture the value and an environment variable.
The variable {{session-id}} can then be used in the desired request. In this example, I’ve just used the as a URL param but it can be used anywhere the {{...}} syntax is accepted.