Need help passing cookies (detailed problem description with pictures)

I’m trying out Katalon and am using the REST API of Microfocus ALM. It requires me to start with a POST Authentication Request:

When I run this request the raw header is:

So far so good. Subsequently I need to do a GET request for a session:

I’m trying to pass the cookie using a Global variable. The script is:

In this code I’m encoding the cookie values, but I have tried without encoding as well. The result (after sending the request) however is:

I’ve tried a number of different approaches, but all of them fail. What should I do? If I cannot get this simple chain of requests to work properly Katalon is of no use, but I cannot believe that to be the case.

Please help.






1 Like
list.each {
    cookiesstring = cookiesstring + UrlEncoder.encode("$it") + ";"

Could you tell us the full package name of UrlEncoder class? I have never seen UrlEncoder class (I know though).

Also would you check how the UrlEncoder.encode("$it") works by inserting a debug print:

list.each {    println "Cookie: \'${it}\' => \'${UrlEncoder.encode(\"${it}\")}\'"    cookiesstring = cookiesstring + UrlEncoder.encode("$it") + ";"}

Encode result:;sticky-key%3D%21vIDOvtcawzBAeVVW3nsCaOopaCNVQhXdyUTdyFz%2FI%2FzWP4rXHySoQoapjSYRzXePf8df8POXFNwuaLU%3D%3B+path%3D%2F%3B+Httponly%3B+Secure;XSRF-TOKEN%3D0ed9b1fd07b0bc232503b961044b48373e2ee030b9cb8f1efb49f586668ddf72%3BPath%3D%2F;ALM_USER%3D182638537d46f141d72619e548122fa5e597a312e34a3e20ed282ecba792435e%3BPath%3D%2F%3BSecure;QCSession%3DNzA5MDg1MztVVHg0V296VjFHT3pObnZtVDF4M0V3Kio7UkVTVCBjbGllbnQ7IDsg%3BPath%3D%2F%3BSecure%3BHttpOnly;LWSSO_COOKIE_KEY%3DEftB17ny37KyfOEwP6LHscYW65ggSuwPLlpUCR-8iCqYq00m69FDFYFJXX6ZXdZAlZo3dmQgH-ul–3kBaiDMYZ45ahcN2YFD3HjpA-FoXiJYMPFxXKc2P8ZwV1nJ-b4WDp0jCuhdXlsstavTchhjvYI7gdlZvt93DldfITbjRItLrhlFIzOXUrHtil1hC1AjlRpHuGEYZNVJnsY44hLY92JPFknyZktecJPkmY7WXDldoFJimNk_jdCuTtcMVNNwGe1Jlneq4x_vKSjmCQ4IcbsP_Aw0ohyuC1QqCGsB9U.%3BPath%3D%2F%3BHTTPOnly;

I’ve managed to solve my problem. No need to encode cookie values after all. I’ve split the cookies from the first response into name/value pairs and add them to the cookie header from the next request one by one thereby omitting the first 2 cookies (in this case klm_tracking_id and sticky-key cookie), after that it worked perfectly and getting the needed JSESSIONID cookie from the response needed for my 3rd API request.

Glad to hear it.

Would you agree to ask the Katalon Forum moderators to bring this post to CLOSED status?

Yes post can be closed

Hi @Paul_Reijling

Could you please post the solution of splitting cookies and how u used it. thanks !

class CookieMonster {


static getCookies(ResponseObject response) {

// Get the contents of the 'Set-Cookie'

def cookiez = (response.getHeaderFields()[ 'Set-Cookie' ])

def name = []

def value = []

def items = 0

def cookiesstring = ''

def pair

cookiez.each({ def cookies ->

pair = cookies.split( '=' )

name.add(pair[ 0 ])

value.add(pair[ 1 ])



// Get cookie names and values to a string omitting unwanted cookies

for ( int i = 0 ; i != items; i++) {

if (((name[i]) != 'name_of_unwanted' ) && ((name[i]) != 'name_of_unwanted' )) {

cookiesstring = ((((cookiesstring + (name[i])) + '=' ) + (value[i])) + ';' )



cookiesstring.substring( 0 , cookiesstring.length() - 1 )

return cookiesstring



Thank you !