I want sink Location data from following rawResponse to an excel file. can't figure it how. here example of my rawResponse: HTTP/1.1 201 Created Date: Fri, 17 Feb 2023 21:40:43 GMT Content-Le...
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!...