API testing using Postman collection

https://${base}.omnipodapps.com/api/v3/provisioning/nonce?base=horizonmobile-int

Above URI is an get request how can i parameterized the environment in katlon studio

1 Like

To parameterize the environment for your API request in Katalon Studio, follow these steps:

1. Define Environment Variables in Profiles

  • Navigate to Profiles: Go to Profiles in Katalon Studio.
  • Add Variable: Create a variable named baseSubdomain in each profile (e.g., Default, QA, Staging) with the appropriate subdomain value (e.g., horizonmobile-int, qa, staging).

2. Create a Parameterized REST Request Object

  • Create New Request: In the Object Repository, create a new Web Service Request object.
  • Set URL with Placeholder: Use the placeholder #{baseSubdomain} in the URL:
https://#{baseSubdomain}.omnipodapps.com/api/v3/provisioning/nonce?base=horizonmobile-int

3. Write the Test Case

  • Send Request with Dynamic Parameter: Use the variable from the selected profile to construct the URL:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

// Retrieve the subdomain from the active profile
def baseSubdomain = GlobalVariable.baseSubdomain

// Send the parameterized request
def response = WS.sendRequest(findTestObject('Get_Nonce_API_Request', [('baseSubdomain'): baseSubdomain]))

// Validate response (example)
WS.verifyResponseStatusCode(response, 200)

4. Switch Environments

  • Select Profile: Use the desired profile (e.g., QA, Staging) in the execution settings to dynamically adjust the baseSubdomain.

This setup allows you to easily switch environments by changing the active profile, ensuring the correct subdomain is used in your API requests.

As @dineshh explained, it is possible to parameterize variables using {} annotation.

First: Create a API test object

On the URL field. set the URL with the variable field using ${}

Define the “base” variable on the Profiles Folder.


I am using staging Execution Profile as an example.

Then, create a new Test Case and use Send Request keyword:
1- Pass the Parametrized_API_test object as the Object for that keyword
2- Add a Variable using “Add” button on the Variables sections and write “base”.
3- The default value of that base variable should be set to GlobalVariable.base (It is suggested on the comboBox.

And that’s it.
If you run the test case (be carefull to previously select Staging profile) you will be using “staging” as the value of that URL.

If you create another Execution Profile, for exaple “Dev” you can create the sabe “base” variable and switch easily between environments.