- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:35 AM
Dear all,
I have the following Json body message that I need to pass to a REST POST API in servicenow.
The json is as below :
{
"status": "sent",
"emailSubject": "Sent from the DocuSign REST API",
"documents": [{
"documentId": "1",
"name": "mydoc.pdf",
"documentBase64": "...." }],
"recipients": {
"signers": [{
"email": "xxx@hotmail.com",
"name": "xxxx",
"recipientId": "1",
"routingOrder": "1"
}],
"carbonCopies": [{
"email": "<instance>@service-now.com",
"name": "SN",
"recipientId": "2",
"routingOrder": "2"
}]
}
}
How to get all the element has variables object in order to inject dynamic content and then build from the object the Json body ?
Thanks for help
regards
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:58 AM
you need to pass the JSON column name as string and then define the value like below sample script.
Sample example:
var r = new sn_ws.RESTMessageV2('test', 'Create Record');
var body =
'{ "fields":{ "customfield_14798":{ "value":"'+current.buService+'" }, "description":"'+current.desc+'", "customfield_14797":"'+current.clean_text+'", "customfield_15073":"'+current.number+'", "issuetype":{ "name":"'+current.temp+'" }, "duedate":"'+current.dd+'", "summary":"'+current.title+'", "reporter":{ "name":"'+current.value+'" }, "project":{ "key":"RM" } }}';
r.setRequestBody(body);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:58 AM
you need to pass the JSON column name as string and then define the value like below sample script.
Sample example:
var r = new sn_ws.RESTMessageV2('test', 'Create Record');
var body =
'{ "fields":{ "customfield_14798":{ "value":"'+current.buService+'" }, "description":"'+current.desc+'", "customfield_14797":"'+current.clean_text+'", "customfield_15073":"'+current.number+'", "issuetype":{ "name":"'+current.temp+'" }, "duedate":"'+current.dd+'", "summary":"'+current.title+'", "reporter":{ "name":"'+current.value+'" }, "project":{ "key":"RM" } }}';
r.setRequestBody(body);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 05:04 AM
Thanks for your reply, will try
As you can see in my post body I need to pass a document base 64 info.
How to convert a file in documentBase64 format in serviceNow script ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 05:31 AM
adding one blog here, kindly refer that.
http://www.john-james-andersen.com/blog/service-now/easy-base64-encoding-in-servicenow.html