Sending cookie as request header in SOAP UI request for leisure web service

I am testing the Rest API using the SOAP UI tool.

First, I hit another API that jSessionid gave me, and then in my actual request, I added a parameter to the request header called "Cookie" and provided this above extracted jsessionid value. Everything worked fine.

I want to somehow dynamically set the cookie / jessionid in the request header without explicitly / manually.

How can I do that?

+7
rest cookies session-cookies jsessionid soapui
source share
2 answers

You can create an application session from the user interface and use cookies that save the session. Get session cookie data from a browser using the browser developer tools. The image shows where cookies are available in the browser: Getting cookie header parameter

In soapUI, create a header attribute with the same value that you received in the browser and run the query. The request will use the same session identifier (JSESSIONID) that is stored in the cookie to trigger the request. The figures below show how to add a cookie value to the header. Adding cookie value o request header

+6
source share

You can easily manipulate cookies with Groovy scripts. In SoapUI, cookies are stored in the cookie storage:

 import com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport def myCookieStore = HttpClientSupport.getHttpClient().getCookieStore() 

You can read all cookies:

 def myCookies = myCookieStore.getCookies() def interestingCookie myCookies.each { if(it.name == "JSESSIONID") interestingCookie = it } 

To create a new cookie in another request:

 import org.apache.http.impl.Cookie.BasicClientCookie def myNewCookie = new BasicClientCookie("cookie_name", "cookie_value") myNewCookie.version = 1 myNewCookie.domain = "qa.test" myCookieStore.addCookie(myNewCookie) 

I have more information on an older blog here .

+2
source share

All Articles