Outbound Rest Integration in ServiceNow PDF
Outbound Rest Integration in ServiceNow PDF
Outbound Rest Integration in ServiceNow PDF
Integration between applications is quite common. In real world you will find that,
mostly applications are integrated with other application is any sense. For example
if you are booking flight, booking train, booking movie ticket, login functionality
using google account, maps, weather details and lots of other things. Applications
use others API's to display information on their platform. In ServiceNow platform it
is very simple to implement ServiceNow rest integration and ServiceNow soap
integration with other applications either it is Uni- Directional or Bi-Directional
integration.
Here in this article we will talk about Outbound Rest Integration in ServiceNow.
Here we will discuss about endpoints, methods, authorization details etc. We will
cover each and every thing about ServiceNow rest integration.
Here in this article we will integrate two ServiceNow application, One instance of
ServiceNow will be treated as Source and Other instance of ServiceNow is treated
as Target.
In Integration Source instance send request to Target instance and Target instance
send back the response . So the concept will remain same for either we will
integrate ServiceNow with any other application as well.
USE CASE:
Integrate two ServiceNow instance. Every time when incident is created in one
ServiceNow instance (source) then incident record with same information will also
get created in another ServiceNow instance (target).
So the solution we will implement to achieve is that we will create rest message
and Business rule in ServiceNow source instance and below are the required
information which we need from Target instance or ServiceNow target instance,
which will be needed while creating the rest message.
1. ENDPOINTS
2. METHODS
3. REQUEST BODY
4. HEADERS (CONTENT TYPE)
5. AUTHORIZATION DETAILS
ENDPOINTS:
Endpoints are the https address where we need to send information or it is the
URL which will accept the web services.
Basically endpoint is the address of the application to whom the source application
wants to communicate.
METHODS:
Methods tell that what source is doing for target instance. For e.g. create records,
update, delete the record etc. Methods are used to perform CRUD operations i.e.
Create, Read, Update and Delete
• GET (to retrieve the record)
• POST (to create the record)
• PUT (to modify the record)
• PATCH (to update the record)
• DELETE (to delete the record)
AUTHORIZATION:
Please find the below script of Business Rule (before business rule) implemented in
ServiceNow source instance:
var response=request.execute();
var requestBody=request.getRequestBody();
var responseBody=response.getBody();
var httpStatus=response.getStatusCode();
gs.log(responseBody);
responseJSON=responseBody.substring(10,responseBody.length-1);
parsedJSON=JSON.parse(responseJSON);
var targetIncidentNumber=parsedJSON['number'];
var targetIncidentsysid=parsedJSON['sys_id'];
})(current, previous);
Please find the below HTTP Request method parameter script mentioned in Rest
Message:
{
"caller_id":"${caller}",
"short_description":"${short_description}",
"category":"${category}",
"impact":"${impact}"
}