how do i extract text from a REST call and use the extracted text to update another REST call.

I have created 2 RESTful service requests in the object repository

  • REST call #1 (GET)
    • This gets a list of tests run on my account for
    • The response contains a test_id for each test.
    • selenium_test_id": 7746595
  • Rest call #2 (PUT )
    • The 2nd REST call sets the test score for a specified test as pass or fail
How do I extract the "selenium_test_id" from REST call #1 and add the extracted text to REST call #2 to set the test score based on the pass/fail result in Katalon studio?

How do I get the status (pass / Fail) of a test case in Katalon studio after it has run?

My aim is to run a test in Katalon studio using CrossBrowserTesting as my device hub, Once the test completes in katalon i would like to check the status pass / fail and update Cross browser testing with a pass / fail based on the status from Katalon.

I added the following code inside a new test case, and then call the test case in my main test
def responseData = WS.sendRequest(findTestObject('List Selenium Test History'))
def slurper = new groovy.json.JsonSlurper()
def result = slurper.parseText(responseData.getResponseBodyContent())
When debugging through the code response data has error 500 but when I run the web service in the objects in katalon it works and I get a result.


Is there a global variable I can use to check status (pass / Fail) of a test case in Katalon studio after it has run?

Based on the variable I can set REST call #2 as pass or fail.

Hi there,

You can add this code to the place you want. The suggested place to add for ‘extract’ code is after REST call #1 and ‘replace’ code is before REST call #2.

You don’t need to add additional packages for it.

Thank you, Vinh Nguyen. Where do I add this code? can I create a custom keyword and if so which packages do I need to install?

Hi there,

To extract “selenium_test_id” from REST call #1 (response variable in my case)

def slurper = new groovy.json.JsonSlurper()
def result = slurper.parseText(response.getResponseBodyContent())
println result.selenium_id

2. Add to REST Call #2 (request in my case)

request = request.setRestUrl("" + result.selenium_id)

Hope it help you in this case

1 Like

How can i extract a number from String.
Ex : 459842 is your one time Verification Code.

I need to extract the number 459842 and place it in input field of other Tab. Does any one help me out.