How to generate JSON payload
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 09:27 PM
Hi, can someone assist me to script this kind of payload (yellow highlighted)
<name>The name of the downtime</name>
<action name="ENFORCE_ON_REPORTS">
</action>
<approver>The approver name</approver>
<category>1</category>
<notification>
<recipients>
<recipient id="24"/>
<recipient id="22"/>
<recipient id="21"/>
</recipients>
</notification>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 09:59 PM
Hi,
If this is for sending xml request in SOAP Message I would encourage to use the variable substitutions for your dynamic values such as WEDNESDAY, FRIDAY etc
please refer below links
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 10:17 PM
Hi,
As per your question you are asking how to generate json payload.
So I assume you have xml and want to convert to json object
Below is the sample script
var
var xml = ''; // your xml string here
var obj = gs.xmlToJSON(xml);
gs.info(JSON.stringify(obj));
Regars
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader