- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 09:35 AM
I have an upcoming requirement to gather integrate ith another system and the response will be in XML.
I need to iterate through the various elements and create records and populate values another table.
I have been looking at converting the XML to a Json Object, to no avail. I have also looked at many pages using the various "child node iterators" but again, I can seem to get t all working.
Using the Rest API explorer I am simply passing
GET https://devXXXXXX.service-now.com/api/now/table/incident?sysparm_query=active%3Dtrue&sysparm_fields=...
and my response
<?xml version="1.0" encoding="UTF-8"?><response><result><number>INC0010021</number><short_description>testpr</short_description></result><result><number>INC0010040</number><short_description>testprxml</short_description></result><result><number>INC0010025</number><short_description>testpr</short_description></result></response>
My intention is to create another record on another table and use the number and short description fields as values on that other table.
Thank you all
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 10:59 PM
Hi Peter,
Please find the below articles to convert the XML response to JSON.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0957116
OR
Use below code in BR
var res_body = response.getBody();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 04:57 PM
Hello Peter,
Please refer below article which has information on how to convert XML to JSON Payload
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0957116
Please mark helpful and correct, if it resolves your issue.
BR,
Suman.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 05:31 PM
Hello Peter,
Please use below code snippet, if you are not able to resolve the issue with my previous reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 10:59 PM
Hi Peter,
Please find the below articles to convert the XML response to JSON.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0957116
OR
Use below code in BR
var res_body = response.getBody();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2024 01:57 AM
Thank you for this. I had seen the snippets from other posts but I had so many variations I simply took out the var results = jsonObj.response.result; and couldnt see it. Appreciate your time.