ServiceNow Instance Setup
This page prepares a ServiceNow instance for the plugin. The steps apply to a production, test or developer instance.
| For tests, request a free Personal Developer Instance (PDI) from the ServiceNow Developer Program. |
Step 1: Activate the ServiceNow Applications
Two ServiceNow applications are not active on every instance. Event Management is needed for event and alarm forwarding. Customer Service Management is needed for cases only.
| Ticket forwarding and CMDB import use the Table API, which is always available. If you need only these features, skip this step. |
Event Management
The Event Web Service API (/api/global/em/jsonv2) is available only when Event Management is active.
Event and alarm forwarding need it.
-
Log in to your instance as an administrator.
-
Open All > System Definition > Plugins.
-
Search for Event Management Core (
sn_em_ai) and install it. -
Wait until the installation is complete. This can take some minutes.
The check of the API follows in Test the API Access, with the integration user from Step 2.
| For quick access to the OpenNMS data in ServiceNow, add Event Management > All Alerts, Event Management > All Events and Service Desk > Incidents to your favorites. |
Customer Service Management (Optional)
The plugin creates cases in the sn_customerservice_case table.
This table exists only when the Customer Service Management (CSM) application is active.
Skip this part when every ticket creates an incident.
-
Log in to your instance as an administrator.
-
Open All > System Definition > Plugins.
-
Search for Case Management Core (
com.sn_customerservice) and install it. Older releases list this plugin as Customer Service. The demo data is not necessary. -
Wait until the installation is complete. This can take some minutes.
| CSM adds its own access control to the instance. On an instance that already runs other applications, such as ITSM, check the effect on the existing users first. See the ServiceNow documentation on activating Customer Service Management. |
The check of the case table follows in Test the API Access, with the integration user from Step 2.
Step 2: Create an Integration User
Create a local user in ServiceNow for the plugin.
| Make the integration user a non-interactive local account, with each authentication type. Set Identity type to Machine, which also sets Web service access only, and select Internal Integration User. The user then cannot log in to the UI and uses its password for API calls only. This also applies on an instance with SSO or MFA. Your SSO users are not affected and see all events, alerts and incidents from the plugin. |
Create the User
-
Log in to your instance as an administrator.
-
Open All > User Administration > Users.
-
Create a new user. The values below are examples:
Field Example value User ID
opennms_user
First Name
OpenNMS
Last Name
Integration
Email
Active
Selected
Identity type
Machine. This sets Web service access only. On a release without this field, select Web service access only.
Internal Integration User
Selected
-
Save the record.
-
Set a strong password with Set Password on the saved record. The password is needed for basic authentication and the OAuth password grant. Client credentials do not need it.
Give the User Its Roles
Open the user record and add these roles:
| Role | Purpose | Needed for |
|---|---|---|
|
Access to the Event Web Service API |
Event and alarm forwarding |
|
Events and alerts in the ServiceNow UI |
Event and alarm forwarding |
|
Read and write incidents, read the CMDB |
Ticket forwarding, CMDB import |
|
Read and write cases |
The roles evt_mgmt_integration and evt_mgmt_user exist only after Event Management is active. The role sn_customerservice_agent exists only after Customer Service Management is active. See Step 1.
|
Test the API Access
A save in the plugin is the quickest check. It tests the connection and reports denied access for each enabled feature. See Plugin Configuration.
The curl commands below show the raw reply. Use them before the plugin is set up, or when a save reports a problem. The replies also show whether the applications from Step 1 are active.
The commands use basic authentication with the password of the user. With client credentials, the user may have no password. Do the check with an access token after Step 3.
New instances restrict basic authentication over the API for the admin user. Do these checks with the integration user, which is not restricted. An admin user needs the role snc_basic_auth_api_access for them.
|
The incident check is a read of the incident table. On an instance where every user reads the incidents they opened, this read succeeds without the itil role. The first incident create then reports the missing role.
|
Event Web Service API:
curl -X POST -u opennms_user:password \
-H "Content-Type: application/json" \
"https://<your-instance>.service-now.com/api/global/em/jsonv2" \
-d '{"records":[{"source":"OpenNMS-Test","event_class":"OpenNMS.Event","node":"test-node","severity":"4","description":"Test event"}]}'
A reply with "events were inserted" means that Event Management is active and the user has access.
Incident Table API:
curl -s -w "\nHTTP Status: %{http_code}\n" -u opennms_user:password \
"https://<your-instance>.service-now.com/api/now/table/incident?sysparm_limit=1"
Case Table API, only with cases:
curl -s -w "\nHTTP Status: %{http_code}\n" -u opennms_user:password \
"https://<your-instance>.service-now.com/api/now/table/sn_customerservice_case?sysparm_limit=1"
| Reply | Meaning |
|---|---|
|
Success |
|
The case table does not exist. Customer Service Management is not active |
|
Wrong credentials |
|
Read access to the table is denied. A role is missing |
|
Event Management is not active |
Step 3: Create an OAuth API Endpoint (Optional)
Do this step for an OAuth authentication type. Basic authentication needs only the integration user from Step 2. An administrator does this step.
Client Credentials Grant
This grant needs Washington DC or later.
-
Set the system property
glide.oauth.inbound.client.credential.grant_type.enabledtotrue. The property does not exist by default. Openhttps://<your-instance>.service-now.com/sys_properties_list.doand create it with the typetrue | falseand the valuetrue. -
Open System OAuth > Inbound integrations and create a Client credentials grant integration.
-
Enter a Name and a Provider name, such as
OpenNMS. -
Set OAuth Application User to the integration user from Step 2. This field ties the client ID and secret to the user. Every token runs as this user and has its roles. Without it, the token request fails with
access_denied. -
Under Auth scope, add
useraccount. ServiceNow shows a warning for this scope. The plugin needs it for the Table API. -
Save the integration. The record shows the Client ID and the Client secret. Copy both into the plugin.
-
The plugin needs no username for this grant. The token runs as the application user, and the plugin checks its access on save.
On a release without Inbound integrations, create the record as described for the password grant. Then set Default Grant Type to Client Credentials and OAuth Application User to the integration user.
Password Grant
-
Open System OAuth > Application Registry.
-
Create a new record of the type Create an OAuth API endpoint for external clients. On Zurich and later, this option is marked Deprecated UI. It still creates the correct record.
-
Enter a name such as
OpenNMS. -
Leave Client Secret empty, and ServiceNow generates one. Or enter your own.
-
Set Refresh Token Lifespan to the value your policy allows. The default is 100 days.
-
Submit the record. ServiceNow then asks for the auth scopes. Add
useraccount. You can also add it later in the Auth Scopes related list of the record. -
Open the record and copy the Client ID and the Client Secret into the plugin. The secret is masked, click the lock icon to show it.
-
In the plugin, enter the integration user from Step 2 with its local password. Each token runs as this user and has its roles.
Test the Token Request
A save in the plugin requests a token and reports an error when the request fails. The curl commands below show the raw reply.
curl -s -X POST "https://<your-instance>.service-now.com/oauth_token.do" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=<client-id>" \
--data-urlencode "client_secret=<client-secret>"
For the password grant, send grant_type=password with username and password instead.
A reply with access_token means that the setup is complete.
A reply with access_denied means that the grant is not enabled or the application user is not set.
A 500 reply directly after you set the system property means that the setting is not active yet. Wait one minute and try again.
Check the roles of the application user with the token:
curl -s -w "\nHTTP Status: %{http_code}\n" -H "Authorization: Bearer <access-token>" \
"https://<your-instance>.service-now.com/api/now/table/incident?sysparm_limit=1"
The reply codes have the same meaning as in Step 2.
A 403 reply with Access to unscoped api is not allowed means that the token has no auth scope.
Tokens issued before you add the auth scope stay unscoped. Delete them under System OAuth > Manage Tokens to get a new token.