Postman - Use part of the response data from one test in another test

Not completely sure what the response data format is from the question but if it's a simple object with just the url property, you could use something simple like this:

var str = pm.response.json().url
pm.environment.set('value', str.split('=', 2)[1])

This will then set the value you need to a variable, for you to use in the next request using with the {{value}} syntax in a POST request body or by using pm.environment.get('value') in one of the test scripts.

Postman

Edit:

If the url property is in an array, you could loop through these and extract the value that way. This would set the variable but if you have more than 1 url property in the array it would set the last one it found.

_.each(pm.response.json(), (arrItem) => {
    pm.environment.set('value', arrItem[0].url.split('=', 2)[1])
})

Postman

Tags:

Postman