- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 08:47 AM
Hi Everyone
I am new to ServiceNow and trying to do the following stuff. I am not getting a lead to do it as I have been using traditional programming IDEs to solve different tasks but did not use an app like ServiceNow earlier. I am trying to do the following:
- make an outbound Rest call to an external RestAPI and get JSON back. (able to do this but the results can not be processed as using Outbound rest messages)
- find a way to process the JSON response with javascript in the test app.
- make authentication with API token with the RestAPI call
Is there any way I could achieve such functionality? Thanks a lot
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 04:10 PM
Check the "Advanced" checkbox.
The body of the script can be generated using REST Message.
- From the Navigator, go to "System Web Services" > " Outbound" > "REST Message".
- Create a new REST Message by clicking on the "New" button.
- Fill in the Endpoint (i.e. enter the URI of the external url. e.g. http://xxx.aaa.com:8080)
- Select "Authenentication type" from pull down
- If there is a HTTP Request header, select the "HTTP Request" tab and insert the required headers.
- Select the "New" button next to the HTTP Methods
- Enter the "Name" and the "HTTP method".
- To test the uri and if there is argument to be passed in the uri, click on the "New" button next to the "Variable Substitution". For example, to replace "id" with some value such as "abc"
- Click the "Test" link under "Related Links" to test the endpoint.
- If all goes well, click on the "Preview Script Usage" link under the "Related Links". This will generate JavaScript code template.
- Paste the generated source code to business rule.
- If using MID Server, edit the source code as needed.
To parse JSON response,
var responseBody = response.getBody();
var response= JSON.parse(responseBody);
for(i=0;i<response.length;i++) {
// process json object
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 06:10 AM
How we call restmsg into BR . In therotical word how we ans this. How we can call restmsg into BR?
Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 09:40 AM
Hi,
No those fields will not be available on any table. I took as example.
If you want to send the JSON then you need to create those output_payload(contains the json) and input payload (will get the response and captures here).
Example: If you need to send the a,b,c fields to x system. Then you can define the JSON and capture on field output_payload. so that we use that field on business rule to send data.
If you need more experience on integrations then refer below video and other which are available on youtube.
https://youtu.be/PC-h8U3Wuso
Hope it helps!!
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 04:37 PM
thanks a lot for referring to that youtube channel. I got a lot to learn from there. The code sample you pasted did not help that much but I got a lot to learn. If you could post a formatted answer, I will mark it as answer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 04:58 PM
Following ServiceNow tutorial explains very well on how to create an outbound REST message.
Following page has an concrete steps to create an outbound REST message to integrate with Google Calendar.
https://dxsherpa.com/blogs/create-a-rest-message-how-to-read-the-docs-integration-part-2/
Lastly, ServiceNow documentation. It will make more sense after going through the above 2 sites. These 3 sites should be sufficient for basic cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 07:47 AM
Thanks for sharing the resources. I will keep it in mind for my next tasks. Thanks a lot.