Hi All,
I am trying the print the API response for the Rest API call which I have made.
Also I am trying to fetch some property values from this call to use them in subsequent calls as input.
Is there a way to achieve this in Katalon?
Any help is much appreciated.
Thanks,
Sampath
groovy.json.JsonOutput
class would help:
See
Thanks alot this helped me to fetch the data.
Can you please also guide me how can I pass this fetched data as variable to the next API call?
I do not see how I can help you.
Please, write your some code first. The code may be wrong, thatās OK.
Show your code to us.
The code would tell us what you want to do, how much you are trained for Groovy programming, and what you need to learn more.
sendOtpResponse = WS.sendRequest(findTestObject(āsendOTPā))
sendOtpResponseText = sendOtpResponse.getResponseText()
JsonSlurper slurper1 = new JsonSlurper()
Map parsedJson1 = slurper1.parseText(sendOtpResponseText)
String auth_Id = parsedJson1.auth_id
println(auth_Id)
String auth_id = āAUTH-BV57PV63UB6Lā
getOtpResponse = WS.sendRequest(findTestObject(āgetOtpā, [(āauth_idā) : auth_id]))
getOtpResponseText = getOtpResponse.getResponseText()\
JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper1.parseText(getOtpResponseText)
String otp = parsedJson.otp_code
println(otp)
This is the code I have written but I am unable to pass the auth_id from the previous sendOtpcall to getOtpcall
Need to know where I am going wrong
I inserted some debug-print statements as follows. Please run it. and show us what messages you see in the console.
import groovy.json.JsonOutput
import com.kms.katalon.core.testobject.TestObject
sendOtpResponse = WS.sendRequest(findTestObject(āsendOTPā))
sendOtpResponseText = sendOtpResponse.getResponseText()
JsonSlurper slurper1 = new JsonSlurper()
//Map parsedJson1 = slurper1.parseText(sendOtpResponseText)
def parsedJson1 = slurper1.parseText(sendOtpResponseText)
println "#1 parsedJson1=${JsonOutput.prettyPrint(parsedJson1)}"
String auth_Id = parsedJson1.auth_id
println("#2 auth_Id=${auth_id}")
String auth_id = āAUTH-BV57PV63UB6Lā
TestObject to = findTestObject(āgetOtpā, [(āauth_idā) : auth_id])
List<TestObjectProperty> list = to.getActiveProperties()
for (TestObjectProperty top : list) {
println "${top.getName()} ${top.getValue()}"
}
getOtpResponse = WS.sendRequest(to)
getOtpResponseText = getOtpResponse.getResponseText()
JsonSlurper slurper = new JsonSlurper()
//Map parsedJson = slurper1.parseText(getOtpResponseText)
def parsedJson = slurper1.parseText(getOtpResponseText)
println "#4 parseJson=${JsonOutput.prettyPrint(parsedJson)}"
String otp = parsedJson.otp_code
println(otp)
Hi,
Below tutorial explains the same
1 Like