Call testcase with cookie

Good morning, everyone,

I have to test an API and I currently have a big blocking point.

I have a first WS that allows the connection and generates a cookie and a second WS to retrieve the information of the connected user.

However, I can’t pass the generated cookie as a parameter of the second WS.

I coded this:

def cookie = GlobalVariable.Token

def connectionResult = WS.callTestCase(findTestCase(‘get user information’), [‘p_Protocol’ : null,‘p_DomainName’ : null,‘p_Path’ : null,‘p_WindowTitle’ : null,‘Cookie’ : cookie])

and a 401 error returned to me.

Does anyone have an idea or has anyone ever encountered this case please?

thank you in advance

Translated with www.DeepL.com/Translator

you need to create that cookie to be able to set it in request:

Cookie myCookie = new Cookie("TokenNameYouNeedSet", tokenFromFirstRequest)
response = WS.sendRequest(findTestObject(requestObject.getObjectId(),[('COOKIE'): myCookie]))

Thank you.
I tried this but when I launch my test case, there is this in the log :

“unable to resolve class Cookie”

import org.openqa.selenium.Cookie