Set a variable from raw text response

Hey @heath.dickinson,

Welcome to the community!! :wave:

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.

pm.environment.set("session-id", pm.response.text())

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.

2 Likes