Forum Discussion

davissoap's avatar
davissoap
Occasional Contributor
8 years ago

Unable to retieve Cookie value

I am testing a rest service which generates a cookie .I am using the following in my  assertion 

if (messageExchange.responseHeaders.containsKey('Set-Cookie')) {
log.info "Found Cookie in the response headers"
def cookiez = messageExchange.responseHeaders['Set-Cookie'].value
cookiez.each { cookies ->
log.info cookies.toString()
}
} else {
log.warn "Not Found Cookie in the response headers"
}

 

it always print Not Found Cookie in the response headers in the log as it doesn't find the coookie.I can see the cookie and its value in http log.is there any configuration i need to do .Any help would be very welcome.

4 Replies

    • davissoap's avatar
      davissoap
      Occasional Contributor

      Thanks for the quick response 

      My apologies for not being descriptive.

       

      I have two redirects.At very redirect i set a cookie.I am trying to retreive the cookie set in the second redirect .I can see the cookie generated in the HTTP logs.But in SOAP UI i am unable to retrive cookie as it is always empty.

      IF i set follow redirect to false I am able to pull the cookie set in the first redirect but it just stops there as "follow redirect" is set  to false.

      but I would like the two redirects to happen and be able to retrieve the cookie set in the second redirect.I tried in post man with no interceptor and I didn't see the cookie genrated in any of the redirects.But when I enabled the interceptor I can see the cookie generated in the secodn interceptor.

       

      pls advise

      • davissoap's avatar
        davissoap
        Occasional Contributor

        In this case the two redirects happen with in the same step.