Passing Cookies to Next Request

The below is the response of my previous request that I have executed and now I wanted to pass the Cookies to Next Request.

I am able to store all “Set-Cookie” to a variable as shown below:
def cookiez = response.getHeaderFields()[‘Set-Cookie’]

I am also doing something below to pass the cookiez to Global Variable like below:
GlobalVariable.cookies = cookiez

I am also passing the Global variable to Next request as shown below:
reponse = WS.sendRequest(findTestObject(‘APIs/Login’, [(‘token’) : GlobalVariable.token, (‘cookies’) : GlobalVariable.cookies]))

But major problem is that cookies are not formatted properly hence katalon studio confused and did not know how to pass this to next request,

Response Header of Previous Request:
“headers” : [ {
“name” : “Set-Cookie”,
“value” : “website#lang=en; Path=/”
}, {
“name” : “Set-Cookie”,
“value” : “ASP.NET_SessionId=mnhowj1lrrrnxi5ujhjj0nxz; Path=/”
}, {
“name” : “Set-Cookie”,
“value” : “__RequestVerificationToken=kDrT58rbE3F3zw2nT3GwZ9tD0BEDj7ij0AqEY8y6HGcIBYfVp9-Shq6xkKyShGtHyUAf_AZ2NSsWG9KB_mJqmFu_sqo1; Path=/”
}, {
“name” : “Set-Cookie”,
“value” : “dtCookie=1$B8CED2B20D0F9458D77AE8AE5231E39E; Domain=.abc.ca; Path=/”
}, {
“name” : “Set-Cookie”,
“value” : “PD_STATEFUL_a29a47c6-3735-11e7-bd2b-000c29d93084=%2F; Path=/”
} ]

When i printed the cookiez variable using println(cookiez) then katalon studio is printing something like this:
[PD_STATEFUL_a29a47c6-3735-11e7-bd2b-000c29d93084=%2F; Path=/, dtCookie=1$4E1D71854B8F48987C5191501B86E4AE; Domain=.abc.ca; Path=/, __RequestVerificationToken=YrNCxc0ZVndVQJzDzO9TokfTXCOWZ-kZoFJi0fq3CXn0_ysrOQwgFVDa2OLXwTRKSg0P5Y-gKcPXoEhxEL1TCQFS2ZA1; Path=/, ASP.NET_SessionId=0qt3sphsmfqwqmjy0xmdlv3o; Path=/, website#lang=en; Path=/]

and then I noticed that when katalon studio is passing the cookies to next request then it only looks for ’ ; (semicolon)" and creates the next cookies.

For example:
Katalon Studio started the scan from
[PD_STATEFUL_a29a47c6-3735-11e7-bd2b-000c29d93084=%2F; here this tool will consider end and going to start with second parameter which is Path=/, here is just comma hence scan continues to next.

Can someone helps me to sort this out? Is there anything else that I need to do?

Everything is very easy with katalon studio but this tool is completely dumb while passing the cookies to next request.

Katalon studio must add something inbuilt capabilities like Postman/Jmeter so that QA shouldn’t need to worry about these things.

What is the value type of GlobalVariable.cookies variable? Have you tried to use the returned cookies value directly instead of directing it into an incompatible variable’s type (just my assumption)?

Thank you Vinh for your reply.

The following is the value of GlobalVariable.cookies but when it actually pass the cookies to request (Header) at that time it changes the format based on " ; (Semicolon)".

[PD_STATEFUL_a29a47c6-3735-11e7-bd2b-000c29d93084=%2F; Path=/, dtCookie=1$4E1D71854B8F48987C5191501B86E4AE; Domain=.abc.ca; Path=/, __RequestVerificationToken=YrNCxc0ZVndVQJzDzO9TokfTXCOWZ-kZoFJi0fq3CXn0_ysrOQwgFVDa2OLXwTRKSg0P5Y-gKcPXoEhxEL1TCQFS2ZA1; Path=/, ASP.NET_SessionId=0qt3sphsmfqwqmjy0xmdlv3o; Path=/, website#lang=en; Path=/]

I don’t know how to return cookies value directly, Would you please give me idea/ or rough solution?

Would you please reply @Zarashima??

what is the purpose of this forum if you don’t want to reply @Zarashima??

Any response we are facing a similar issue.

Try below URL, hope you will find your answer: