Handle Response Messages


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/handle-response-messages.html

In the api testing, I need to verify the response , response contains n number of collections like n number of user details(each user have multiple fields) , so that I need to verify each persons age (I need to verify the age is 25) so that is there any way to traverse through each user to check weather the age is 25 or not( I need to implement loop concepts and I have to pass the iteration value to the response array), is there any way to implement this scenario?

there may be many solutions: a recursive function to parse the response, json schema validation …
some discussions on this matter here:

how to use getResponseText() function
pls help me out

getResponseText is not present in keywords browser

You can use it in Script mode.

ResponseObject ro = WS.sendRequest(findTestObject("my/api/object"))
String response = ro.getResponseText()
1 Like

thank you , it worked

1 Like

Is there a way instead of using Element locator , I just want to comb the whole response to fined a value.

I’m not sure what you were asking for.

getResponseText() is not supporting for Katalon 5.7 version…plz suggest some alternative to get the text

getResponseBodyContent()

What does “not working” mean?

Hello - I am trying to write an XML response (the entire body) to a file. I have been trying the getResponseBodyContent() but instead of the entire response body it is only giving me the first line of the body (it is a very large response with about 85k lines).

Here is the code:

ResponseObject responseObj = WSResponseManager.getInstance().getCurrentResponse()
String response = responseObj.getResponseBodyContent()

Any ideas what I am doing wrong?

Hi, if the locator support use json to filter some special node ? i have tried a locator that use the json fitler function , like this ‘entity[?(fieldName ==‘special value’)]’ , but throw error in the step of
parseAndExecuteExpressionForJson
Katalon version :7.8.1