The next step is the interesting one. It iterates over the multline string. If the string contains "Location", then assign to a var. The replace then removes the "Location:" prefix and finally returns the actual location value.
// Get raw response from previous step - this is where you'd pull it in from your service call... def rawResponse = context.expand( '${Get Raw Response - Groovy Script#result}' )
// Create a var to hold location. def location = "";
// Find the line containing Location and assign to location var. rawResponse.eachLine { if (it =~ /Location/) { location = it; } }
// Remove the Location: prefix location = location.replace("Location:", "");
// return Location to whatever has called this script. E.g. a data sink... return location;
Finally, how to use in a datasink, just call the Groovy script!...