Set response value as Variable in Test

You’re using pm.response.text() here which isn’t required for a JSON response, as you can use .json() to get the data in a format that’s easily parsable.

This is what you would need to get the first object’s id value:

let response = pm.response.json();
pm.environment.set('folderID', response.data[0].id);

Ensure that you have an environment file created and selected or it will not capture the variable.


I wrote this a while ago about getting different values from a JSON response, it may help you here: