Forum Discussion

DMc-Cabe's avatar
DMc-Cabe
Occasional Contributor
12 years ago

[Res] Passing Cookie to REST Request Header

hi there

I have used groovy to extract the Set-Cookie from a login request but I'm having difficulties passing the value to the header or a new request

the cookie is stored as $jsesid in test step called "Extract Cookie Values" and I'm trying to pass it as an Cookie called Authtoken in test Step "Create new entity" I've tried several different approaches but none work

I set Property in the Extract Cookie Values test step via :

testRunner.testCase.getTestStepByName("Create new entity")setPropertyValue( "cookie", "$jsesid" )

and then try to use it in Test Step "Create New Entity" as follows :

Header = Authtoken Value = ${#Extract Cookie Values2#jsesid}

This doesn't seem to pick up the value of $jsesid

could somone tell me what i'm doing wrong please?

thanks

2 Replies

  • DMc-Cabe's avatar
    DMc-Cabe
    Occasional Contributor
    I figured it out

    In the test step which extracts the Cookie Value, I created a Global property called Cookie

    com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties.setPropertyValue('Cookie',"$myCookie")


    Then in the "Create New Entity" step, I referenced the Cookie property in the Header section by Header=Cookie and Value=${Cookie}