cancel
Showing results for 
Search instead for 
Did you mean: 

How i tranfer a cookie from a response (raw) in a next step and send it there

Highlighted
Regular Visitor

How i tranfer a cookie from a response (raw) in a next step and send it there

Hello,

I am beginning to work with SoapUI and so my level is not high and so a have a question..

I have a Rest-Service and i must login on a website and get in the response a cookie.

For the next steps i must use and send this cookie on a other website to be able to test on this site the api.

So, now my question. How can i transfer this cookie in the next step and send it?


Thanks.

 

Best Regards

Uwe

3 REPLIES 3
Highlighted
Community Hero

Re: How i tranfer a cookie from a response (raw) in a next step and send it there

Hi,

 

If I understand correctly - this seems fairly straight forward - if I'm getting the gist

 

the cookie's in the response headers - right?  There's a bit of groovyscript one of the other lads on the forum gave me to do this.

 

Essentially  you need to perform a property transfer, grabbing the cookie's value writing it either directly to the subsequent request or a Properties step.  I did the same thing on a test case and it had the following steps

 

1st REST request step (generates the cookie)

Groovy step

Properties step

2nd REST request step

 

The code to grab the cookie's value from the 1st REST step headers and save it to the Properties step is as follows:

 

//Takes one of the elements of the response Header
def value = testRunner.testCase.testSteps["1st REST request step)"].testRequest.response.responseHeaders["cookieName"]

//Read this value into a parameter
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils.setPropertyValue("Properties", "cookieName",value[0])

If I understand what you need - this will do it - if I don't then I've wasted your time reading this and mine typing this out! 🙂

 

Cheers!

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Re: How i tranfer a cookie from a response (raw) in a next step and send it there

Just right click on the test case -> settings -> maintain http session. This should do it...



If my answer helped please click on the 'Accept as Solution' button.
Highlighted
Moderator

Re: How i tranfer a cookie from a response (raw) in a next step and send it there

Hi all,

 

Thanks a lot, Community Leaders!

 

@Rincewind, did the above suggestions help you?
If your question was answered, can you please mark the reply that helped you as a Solution so that other users could find it easily in the future?

Thanks in advance,

 

 


Olga Terentieva
SmartBear Assistant Community Manager

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Filtering data retrieved from a DataSource

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors