Assign global variable in the HTTP header of a WebService request



Is there a way to call global variables (say from my execution profile) and assign it as part of the HTTP header of a web service request?

I’m using Katalon 5.10.1



I’m also wondering the same thing.
In my case, I get an authentication token from a rest request, then I assign the token to a global variable. I’d like to use that global variable in the headers of other web service objects during run time for authentication. Is there a way to do it?


see the doc:

using the variables tab you can declare a variable having the value as the global variable you need, or just call the request object from the testcase passing the desired global as a parameter


Thank you for pointing that out! It did the job


how it works tell me please ?


Hi, here’s how I’ve solved my authentication token drama:

  1. First, I’ve created a global variable of type String, with an empty value. I’ve called it ‘AuthToken’ or whatever.

  2. Then I have a test listener that executes before every test suite and sends a request to the authentication endpoint of my web app. This web service call gets an authentication token in the response body.

  3. In that webservice object that fetches the token, I’ve written a line of code that assigns the content of the response (the auth token itself) to the AuthToken global variable. Here’s how it looks:

     def token = response.getResponseText()
     GlobalVariable.AuthToken = String.format("Bearer %s", token) // note the "Bearer" part
  4. Now that I have the authentication token in my global variable, I can use it in the headers of my other web service calls for authentication.

  5. On your other web service objects, create a new variable and set it to point to your global variable with the token.

  6. Then in the HTTP Header tab, add a new Authorization property and set its value to ${name_of_your_variable}

The last two steps are explained with more details in the “Parameterize a Web Service Object” link somewhere above. There could be an easier way that I’ve missed, but oh well. This works for me :sweat_smile: