How do i store dynamic session id in variable

I am having some difficulty to get dynamic session id to store in variable

even i try below

tell me about session

Create global variable in the profile level.

ex: in my scenario, I have created one global variable called ‘token’.

Then Call your post method, which you have created in the object repository. Like below code.

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import static org.assertj.core.api.Assertions.*
import com.kms.katalon.core.testobject.RequestObject as RequestObject
import com.kms.katalon.core.testobject.ResponseObject as ResponseObject
import com.kms.katalon.core.webservice.verification.WSResponseManager as WSResponseManager
import groovy.json.JsonSlurper as JsonSlurper
import groovy.json.JsonSlurper


def token
String tokenGen() {
def response = WS.sendRequest(findTestObject(‘GenerateAccessToken’))
def jsonSlurper = new JsonSlurper()
def slurper = new JsonSlurper()
def result = slurper.parseText(response.getResponseBodyContent())
def token = result.access_token
WS.verifyResponseStatusCode(response, 200)
GlobalVariable.token = token


Using this code you can get any value from your response.

Please reach out to me, if you have any questions.

Thanks… That worked out.

1 Like

Hi @Siva1 I was in need of same working on token.
Followed the steps by creating a global variable ‘token’
My token values is not working with other requests


please let me know if my object path is fine ?

you have to pass your token global variable as mentioned in the below screenshot.

1 Like