Web service request is not using global variable token

I am new to Katalon and automation. I have a post request that creates a bearer token. I have created a global variable that calls that post request. My next post request needs to use the token but I am not having any luck. Any help would be greatly appreciated.

Web Service Request to get token

HTTP Header tab

Verification tab script
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 com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords 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


Default profile Global Variable

Web Service Request that needs to call the Global Variable
Header tab

HTTP Header


Verification script
import static org.assertj.core.api.Assertions.*

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webservice.verification.WSResponseManager

import groovy.json.JsonSlurper
import internal.GlobalVariable as GlobalVariable

RequestObject request = WSResponseManager.getInstance().getCurrentRequest()

ResponseObject response = WSResponseManager.getInstance().getCurrentResponse()

Defined global variable


i think when you use global variable in following request you should write it as



Thank you for your suggestion. I cannot use the global variable in the request method as the URL is not the same as my request. I did add it to the HTTP Header and I am still receiving a 403 forbidden.

and this GlobalVariable.token contains also “Bearer” ? my guess is whole that should be

Autorization : Bearer ${GlobalVariable.token}

not sure since i dont know your app

Thanks. I have tried
Authorization : Bearer ${GlobalVariable.token}
Authorization : ${GlobalVariable.token}
Authorization : Bearer ${token}
Authorization ${token}

I still receive a 403. Not sure what to do next.

wait … where you get 403? in script or when you try to execute from Object repository?

When I execute from the object repository.

That would be the second service POST request that needs the previously generated token to get past the 403

i’m not sure (i’m sure for 90%) that Global Variables will store values between 2 executions from TO repository …

Thanks, I had to call the auth test case, which calls the token post and parses it to save the global variable, in my other test cases and it works.