Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to generate JSON payload

Community Alums
Not applicable

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>

6 REPLIES 6

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

https://docs.servicenow.com/bundle/orlando-application-development/page/integrate/outbound-soap/conc...

https://community.servicenow.com/community?id=community_question&sys_id=fa0ac369db5cdbc01dcaf3231f96...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader