Get session cookie in SendRequest item

Hi guys,

I am trying to verify the response value of RESTful request. In creating the Web Service Request, I need to specify all HTTP header information, one of which is Cookie.

As far as I understand, Cookie is generated per login session, and cannot be pre-specified. However, it seems that Katalon Studio does not support getting browser cookie on the run.

So my question, is there a way to program into the script to retrieve Cookie information of the current login session?

Thanks

5 Likes

Hello Eric
cooke, if set is in response header something like this:

response = WS.sendRequest(reqObj)
println response.getHeaderFields()['Set-Cookie']
1 Like

Hi Team,
I have a HTTPS RESTful webservce URI, one POST request shows Status : 200(for Login) with Jsessionid: 5382856D0F7ABB07F748B034BBB6603C
and another POST RESTful webservce shows Status : 401 Unauthorized with Jsessionid: 8A3F7887C130C1447B3201201AF76554.
Please let me know how can I handle this

Hello Raj,
do you also recieve some token from login request?

Thanks Andrej, for your updates.

I can’t see any Token and for you information, Please find below response(s) for different POST URIs.
Note: I have one more query that is my RESTful URL is not complete.
Ex:

  1. Given URL: https://Domain/xxx/login, but it shows Path=/xxx/

  2. Given https, but is shown HttpOnly().

  3. For **login(POST method) **below is the Response I received, observed in Header

Transfer-Encoding: chunked

X-Frame-Options: SAMEORIGIN

HTTP/1.1 200 OK

Cache-Control: no-cache, no-store, max-age=0, must-revalidate

Server: Apache-Coyote/1.1

X-Content-Type-Options: nosniff

Set-Cookie: JSESSIONID=37732DB2684E2363F353875C0D08ACAE; Path=/xxx/; HttpOnly

Expires: 0

Pragma: no-cache

X-XSS-Protection: 1; mode=block

Date: Wed, 15 Aug 2018 10:19:16 GMT

Content-Type: text/plain

  1. For next **URI(POST method) **below is the **Response **I received, observed in Header

Transfer-Encoding: chunked

X-Frame-Options: SAMEORIGIN

HTTP/1.1 401 Unauthorized

Cache-Control: no-cache, no-store, max-age=0, must-revalidate

Server: Apache-Coyote/1.1

X-Content-Type-Options: nosniff

Set-Cookie: JSESSIONID=D0CCB85578291083C11556720996B755; Path=/xxx/; HttpOnly

Expires: 0

Pragma: no-cache

X-XSS-Protection: 1; mode=block

Date: Wed, 15 Aug 2018 10:23:48 GMT

Content-Type: text/plain

Hi Team,
Are there any updates on this?
Thanks.

just question, did you try to set cookie with JSESSIONID in 2nd call?

Haven’t set any cookie, Just setup the RESTful API in different calls and when try to run individually one gets passed and other fails. Is there possibility how can I disable/delete cookies for different calls.