To send alert notifications to a REST API such as ServiceNow, create a notification group (Configure > Notification Groups) using a custom script:

  1. To use a custom script, go to the Delivery Address section and click Add.
  2. In the address editor, select the Script address type.
  3. In the Custom Script file field, enter the script followed by the required variables.

There are several custom scripts available for interacting with a REST API:

Script Type Example
url_executor.cs HTTP GET url_executor.cs “http://www.example.com/url_to_call”
url_executor_pwd.cs HTTP GET with basic authentication url_executor_pwd.cs “http://www.example.com/url_to_call” “Username” “Password”
Url_PostExecutor.cs HTTP POST with the content of a custom Alert Template Url_PostExecutor.cs “http://www.example.com/url_to_call” “123456” “Username” “Password” “\nAccept:application/json\nContent-Type:application/json”

Available arguments for url_executor.cs:

  • <URL> – address to call.

Available arguments for url_executor_pwd.cs:

  • <URL> – address to call.
  • <username><password>- authentication parameters.

For Url_PostExecutor.cs use the available arguments in the provided order:

  1. <URL> – address to call.
  2. <Template ID> – custom alert template ID. If the parameter is omitted the default alert template is used.
  3. <Username><Password>- authentication parameters.
  4. <CustomHeaders> – list of custom headers separated by /n (the script accepts a maximum number of 5 variables, so if you require multiple headers, you should include them in a list separated by \n as shown in the example above).
  5. <Method> – HTTP method for RESTful Services.
  6. <URLUptime> – address to send Uptime alerts.
  7. <TemplateIDUptime> – custom template ID for Uptime alerts. If the parameter is omitted the default alert template is used.
  8. <UsernameUptime><PasswordUptime>- authentication parameters.
  9. <CustomHeadersUptime> – list of custom headers separated by /n.
  10. <MethodUptime> – HTTP method for RESTful Services.

Be aware that to omit a parameter followed by other parameters it is important to leave the related quotation marks empty:

Url_PostExecutor.cs "http://www.example.com" "123456" "" "" "" "" "http://www.UptimeCallURL.com"

Find a Template ID in the URL bar of the related template edit page (Configure > Alert Templates).

Sending Uptime Alerts with Url_PostExecutor.cs

The Url_PostExecutor.cs script supports sending Uptime alerts to the specified URL address after the device has reported successful monitoring results. In the case when the <TemplateIDUptime> argument is specified the script will use the corresponding alert template to send Uptime alerts.

Herewith, if the <URLUptime> argument exists the network settings provided in <UsernameUptime>, <PasswordUptime>, <CustomHeadersUptime>, <MethodUptime> will be used to perform a call.

Example:

The following script will send both Downtime and Uptime alerts to http://www.example.com using corresponding templates:

Url_PostExecutor.cs "http://www.example.com" "123456" "" "" "" "" "" "321789"

The following script will send Downtime alerts to http://www.example.com and Uptime alerts to http://www.UptimeCallURL.com. To authenticate the call in the case of an Uptime alert “User1″ and “Password1” will be used:

Url_PostExecutor.cs "http://www.example.com" "123456" "" "" "" "" "http://www.UptimeCallURL.com" "321789" "User1" "Password1"

Posting Specific Variables with Url_PostExecutor.cs

When using the Url_PostExecutor.cs script to post variables to a site you will also need to create a custom template to include the necessary variables:

  1. Navigate to Configure > Alerts Templates, and select the option to create a new template.
  2. Then in the source fields, add the necessary variables.

Check the available variables below:

<%Contact_Full_Name%>
<%Contact_Org_Name%>
<%Contact_Title_Name%>
<%Site_Name%>
<%Monitor_Datetime%>
<%Duration%>
<%Location%>
<%TaskInfo%>
<%TaskType%>
<%Task_Name%>
<%Error_Code%>
<%Error_Dscr%>
<%Reason%>

To create a properly formatted REST API call to your ServiceNow Account, find out the proper URL and format required to send the data, check out the ServiceNow Documentation at https://express.servicenow.com/support/documentation/c_restapiexplorer/