- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 03:22 PM - edited 02-04-2025 03:24 PM
Hello All,
"Content": [
{
"client": "123",
"Name": " Name1 "
},
{
"client": "123",
"Name": “Name2 "
},
{
"client": "123",
"Name": "Name3"
}
]
In the Below REST message content field I can only pass 1 Name, how do i pass multiple Names and clients dynamically?
REST Message Content Field
"Content": [
{
"Client": "${Client}",
"Name": "${Name}"
}
]
Solved! Go to Solution.
- Labels:
-
API
-
Integrations
-
REST
-
rest API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 07:23 PM
you can use variable substitution and replace that in REST Message body while using script
"Content" : "${content}"
then use script to form the JSON array and replace like this
Note: this is just an example; enhance it as per your requirement
var arr = [];
for (var i = 0; i < 3; i++) {
var obj = {};
obj['client'] = '123';
obj['Name'] = 'Name1';
arr.push(obj);
}
var request = new sn_ws.RESTMessageV2('name of rest message', 'name of http method');
request.setStringParameter("content", JSON.stringify(arr));
var response = request.execute();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 07:23 PM
you can use variable substitution and replace that in REST Message body while using script
"Content" : "${content}"
then use script to form the JSON array and replace like this
Note: this is just an example; enhance it as per your requirement
var arr = [];
for (var i = 0; i < 3; i++) {
var obj = {};
obj['client'] = '123';
obj['Name'] = 'Name1';
arr.push(obj);
}
var request = new sn_ws.RESTMessageV2('name of rest message', 'name of http method');
request.setStringParameter("content", JSON.stringify(arr));
var response = request.execute();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 08:29 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader