Business rule and REST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 09:00 AM
Hi there,
I am very new to Service NOW. I was trying to accomplish that every time an incident is created, I send a REST post request to an external server. I tried to follow the guide https://express.servicenow.com/support/videos/servicenow-express-outbound-rest/
So I have my outbound rest call defined and tested and that works fine:
But once I try to create a business rule ( I do this as the admin user), something weird happens, the web tab appears but shortly after the page has loaded the tab disappears...
When opening the page:
After loading is completed:
So then I tried with the Advanced option and added the code I retrieved from the outbound section, it looks like this:
try {
var r = new sn_ws.RESTMessageV2('Change record', 'UPDATE EXTERNALLY');
r.setStringParameterNoEscape('close_date', current.resolved_at);
r.setStringParameterNoEscape('INCIDENT_NUMBER', current.number);
r.setStringParameterNoEscape('inc_id', current.number);
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthentication(authentication type, profile name);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
However, nothing happens... I was monitoring my server, but no calls are received there either... Am I missing something all too obvious?
thanks!
Kind regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 05:51 PM
You need to set the REST Type.
var r = new sn_ws.RESTMessageV2('Change record', 'POST'); // POST or GET based on what you need.
If that doesn't work, you can try something like below.
var method = "post";
var endpoint = 'https://www.your_endpoint_'
var rm = new sn_ws.RESTMessageV2();
rm.setHttpMethod(method);
rm.setEndpoint(endpoint);
var body = { some JSON stuff };
rm.setRequestHeader("Content-type", "application/json");
rm.setRequestBody(body);
var response = rm.execute();
var responseBody = new JSON().decode(response.getBody());
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2017 02:18 AM
Hi AA,
The link your have referred to
https://express.servicenow.com/support/videos/servicenow-express-outbound-rest/
has guidance on how you create outbound REST on the Express platform, this platform does not support scripting
https://express.servicenow.com/support/forums/topic/service-now-express-differences/
Your screenshots indicate you are implementing on Enterprise product so you should check out the Enterprise documentation.
This link, which includes a video, would be a good starting point.
If the reply was informational, please like, mark as helpful or mark as correct!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 09:14 AM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here:
Outbound REST Web Service
Visit http://docs.servicenow.com for the latest product documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2017 03:21 AM
Hi AA,
Below links will help you in unsderstanding Outbouund rest and REST APIs
Outbound REST Web Service - ServiceNow Wiki
ServiceNow Integration (REST) - YouTube
Integration Best Practices — Outbound Web Services | John Andersen
You can write back to me if you still face problems. I recently gone through REST challenges and can you help you.
Thanks
Neeraj