Verifying REST xml response

Is that possible to verify xml response of REST service in katalon studio? If not can we convert xml response into json response and verify? Please give me some suggestions for the same. If possible, please share some piece of code.

Is that possible to verify xml response of REST service in katalon studio? If not can we convert xml response into json response and verify? Please give me some suggestions for the same. If possible, please share some piece of code.

Yes, you can. Please refer to the following steps:
1. Download JSON jar from this page: http://mvnrepository.com/artifact/org.json/json/20140107
2. Import .jar file into your project: https://docs.katalon.com/display/KD/External+Libraries
3. Adjust your test case using conversion script to convert XML to JSON. Below is sample script where ‘xmlJSONObj.toString(textIndent)’ is the final result after conversion.

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.json.JSONObject as JSONObject
import org.json.XML as XML
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

ResponseObject response = WS.sendRequest(findTestObject(‘REST_CommentDetails’))
int textIndent = 2
JSONObject xmlJSONObj = XML.toJSONObject(response.getResponseBodyContent())
xmlJSONObj.toString(textIndent)

Thanks

____________________
Thank you for choosing Katalon Studio as your automation solution.
Your feedback is needed to make Katalon Studio a better tool, take the survey at: https://goo.gl/S25NVO

2 Likes

Thanks for the quick response :slight_smile:

How can i extract json path of a particular node from the converted response in to order to use for VerifyElementPropertyValue.

thank you so much.