How to retrieve cookies from REST API response

How do i retrieve cookies information from the response returned by an REST API request. I tried the response mentioned in one of the posts:
def response = WS.sendRequest(findTestObject(‘REST_CommentDetails’))
headerFields = response.getHeaderFields()
println headerFields[‘Set-Cookie’]
Unfortunately, it is not printing out the cookies. I tried Get-Cookie, Cookie and cookies as well as printing out the whole header fields and the cookies don’t seem to be there. I verified with Postman that it is indeed returning the cookies. Any help would be appreciated.
Thanks, Nanda

Apologies, I had “Set-cookie” instead of “Set-Cookie”. You can close this thread. It retrieves the cookies with “Set-Cookie”.

Best, Nanda

2 Likes

Hi
Can the Cookie be passed as a global variable?

Cheers