ServiceNow Integration - Step by step guide

Vijayc1
Tera Expert

ServiceNow Integration – Step by Step Guide

1. Introduction

ServiceNow integrations allow external systems to send and receive data with ServiceNow using standard protocols like REST, SOAP, MID Server, and APIs.
Integrations help automate processes, reduce manual work, and ensure data consistency across systems.

 

2. Types of Integration in ServiceNow

ServiceNow supports multiple integration methods:

  • REST Integration (Most commonly used)

  • SOAP Integration

  • MID Server Integration (for on-prem systems)

  • JDBC Integration

  • Email Integration

  • Import Set Integration

3. Prerequisites

Before building integration:

  • API endpoint details (URL)

  • Authentication details (Basic / OAuth / API Key)

  • Request & Response format (JSON / XML)

  • HTTP method (GET, POST, PUT, DELETE)

 

Scenario Example

Use Case:
Create an Incident in ServiceNow from an external system using REST API.


6. Step 1: Create a Scripted REST API

  1. Navigate to System Web Services → Scripted REST APIs

  2. Click New

  3. Provide:

    • Name: External Incident API

    • API ID: external_incident

  4. Save the record


7. Step 2: Create a Resource

  1. Under the API, click New Resource

  2. Provide:

    • Resource Name: Create Incident

    • HTTP Method: POST

    • Relative Path: /createIncident

  3. Save


8. Step 3: Write Script for Incident Creation

 

(function process(request, response) {

    var body = request.body.data;

    var inc = new GlideRecord('incident');
    inc.initialize();
    inc.short_description = body.short_description;
    inc.description = body.description;
    inc.caller_id = body.caller;
    var incidentSysId = inc.insert();

    response.setStatus(201);
    response.setBody({
        status: "Success",
        incident_sys_id: incidentSysId
    });

})(request, response);

9. Step 4: Test Using REST API Explorer

  1. Go to System Web Services → REST API Explorer

  2. Select your API and Resource

  3. Provide request body (JSON)

 
{
  "short_description": "Network issue",
  "description": "Unable to connect to VPN",
  "caller": "admin"
}
  1. Click Send

  2. Verify incident creation


10. Step 5: Authentication Setup

Common authentication methods:

  • Basic Authentication

  • OAuth 2.0

  • API Key

For secure production integrations, OAuth is recommended.


11. Step 6: Error Handling & Logging

Always add:

  • Try–catch blocks

  • Proper error response

  • Logs using gs.info() or custom tables

Example:

 

try {
   // business logic
} catch (e) {
   response.setStatus(500);
   response.setBody({
     error: e.message
   });
}

12. Outbound Integration (ServiceNow → External System)

For calling external APIs from ServiceNow:

  1. Go to System Web Services → Outbound → REST Message

  2. Create REST Message

  3. Configure endpoint, authentication, headers

  4. Call it via:

var r = new sn_ws.RESTMessageV2('External API', 'post');
var response = r.execute();

13. Best Practices

  • Use Script Includes for reusable logic

  • Avoid hardcoding credentials

  • Use MID Server for on-prem systems

  • Enable API rate limiting

  • Log integration errors separately

 

Thanks & Regards,

Vijay Chorge.

 

 

If you found this blog helpful, please mark it as Helpful.

 

 

 

4 REPLIES 4

Dr Atul G- LNG
Tera Patron

Hi @Vijayc1 

Could you please add the Prefix blog or article so that it’s easy for readers to understand whether it is knowledge or Question.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

GlideFather
Tera Patron

Hi @Vijayc1,

 

I have a few questions regarding your post, I hope you re okay to discuss it further.

 

#1 You say "ServiceNow integrations allow external systems to send and receive data with ServiceNow using standard protocols like REST, SOAP, MID Server, and APIs."

  • are you really sure that MID server and API are protocols?

#3 Perhaps explaining what represnt each method of could help in such an overview.  E.g. difference between PUT and PATCH..

 

#8 it says "Write script" - it's quite vague.. what kind of script would it be? a business rule, transform script - onBefore, orAfter, or what script exactly ....? have you tested that it really works?

 

#12 - Outbound Integration (ServiceNow → External System)

  • you didn't mention inbound integration, was it on purpose?
  • it seems like integrations according to your overview are only one-way..

#13 can you give some example of the script include? 

 

And also, for such descriptive post, I miss information about import set table, transform script, transform maps, mappings, and most importantly (!!!!) IntegrationHub which is the most recommended tool for integrations...

 

And the numbering order is quite chaotic :((

 

_____
No AI was used in the writing of this post. Pure #GlideFather only

Hi there, for completeness on this topic, read & bookmark this important blog post: Integration Design - How to choose the best pattern to integrate ServiceNow with other systems


Please mark it as helpful and accept it as a solution if it helps you in any way.