0% found this document useful (0 votes)
12 views24 pages

Rest Integrations

Rest

Uploaded by

bhumika8917
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views24 pages

Rest Integrations

Rest

Uploaded by

bhumika8917
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.

in

REST Integration
Integration: Integration is the ability for different tools to talk to each other and exchange data.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

One Way Integration (Uni-directional)

Only one tool will send the data and second tool will receive the data

SOURCE TARGET

Two Way Integration (Bi-directional):


Data will be exchanged between both the tools

SOURCE TARGET

Inbound Integration:
Requests which are incoming to ServiceNow is inbound integration.
Example: Using the inbound API to insert a new incident Request.

Inbound
ServiceNow Third-Party Tools

Outbound Integration:
Requests which are going from ServiceNow is outbound integration

Outbound
ServiceNow Third-Party Tools

API [Application Programming Interface]

An API is set of definitions and protocols that allow one application to communicate with other.
It is not necessary that API means WEB API, We can have API with local files
Example: Jar files, Stream API, Collections and same way other libraries.
WEB API:
Similarly Web Services, Web API is an API available on web.
Web Service:
1. Web Service is a piece of software that makes itself available over the internet.
2. Web Service has collection protocols and standards are used to exchange data between
applications or systems
3. The exchange of data is preferably in standard formats like JSON or XML.
Example:
1. Retrieve information about TVs from Amazon.
2. Submit an order to Amazon

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Type of web services


1. SOAP
2. REST
3. GraphQL

Web service and web API, both are used to communicate for two machines over internet.

Web API vs Web Service

Web Serviced API


All web services are APIs. All APIs are not web services.

Responses are formatted using Web API’s


MediaType Formatter into XML, JSON, or any other
It supports XML. given format.
You need a SOAP protocol to send or receive and
data over the network. Therefore, it does not
havelight-weight architecture. API has a light-weight architecture.
It can be used by a client who understands JSON or
It can be used by any client who understands XML. XML.
Web service uses three styles: REST, SOAP, and XML-
RPC for communication. API can be used for any style of communication.
It provides support for the HTTP/s protocol: URL
It provides supports only for the HTTP protocol. Request/Response Headers, etc.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

SOAP [Simple Object Access Protocol]:

1. It is a Protocol
2. Can work on almost any internet protocol
3. Permits only XML.
4. SOAP support SSL and WS-Security
5. It is a Envelope
6. Requires more bandwidth

REST [Representational State Transfer]:

REST defines a set of functions through which we can send requests and receive responses from other
tools or applications via http protocol
1. REST is an architectural style for building web services.
2. Works mostly HTTP
3. REST uses for all 4 CRUD operations.
4. Requires less bandwidth
5. REST permits not only XML and file types like JSON, HTML
6. URI exposes the business logic
7. Restful web service, expose API from your application in secure, uniform, stateless
manner to the calling client

Difference between SOAP and REST

SOAP REST
1. SOAP is a protocol. 1. REST is an architectural style.
2. SOAP stands for Simple Object Access Protocol. 2. REST stands for Representational State Transfer.
3. REST can use SOAP web services because it is a concept
3. SOAP can't use REST because it is a protocol. and can use any protocol like HTTP, SOAP.
4. SOAP uses services interfaces to expose the
business logic. 4. REST uses URI to expose business logic.
5. JAX-WS is the java API for SOAP web services. 5. JAX-RS is the java API for RESTful web services.
6. SOAP defines standards to be strictly followed. 6. REST does not define too much standards like SOAP.
7. SOAP requires more bandwidth and resource
than REST. 7. REST requires less bandwidth and resource than SOAP.
8. REST permits different data format such as Plain text,
8. SOAP permits XML data format only. HTML, XML, JSON etc.
9. SOAP is less preferred than REST. 9. REST more preferred than SOAP.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

URI, URN and URL:

1. URI (Uniform Resource Identifier)


Definition: A URI is a string of characters that uniquely identifies a resource on the internet. It can
refer to a resource by location, name, or both.
Key Points:
• A URI can be used to identify any resource, such as a webpage, an image, or a file.
• It is a broader category that includes both URLs and URNs.
Example:
• A URI could be: https://www.example.com/resource/12345
• This URI identifies a resource located at a specific address.
Diagram:
+---------------------+
| URI |
+---------------------+
| URL | URN |
+-------------+-------+

2. URL (Uniform Resource Locator)


Definition: A URL is a specific type of URI that provides the means to locate a resource on the web.
Key Points:
• A URL includes a protocol (e.g., HTTP, HTTPS, FTP) and the address of the resource.
• It is commonly referred to as the web address.
Example:
• A URL could be: https://www.example.com/index.html
• Protocol: https
• Domain: www.example.com
• Path: /index.html
Diagram:
+---------------------+
| URL |
+---------------------+
| Protocol: https |
| Domain: www.example.com |
| Path: /index.html |
+---------------------+

3. URN (Uniform Resource Name)


Definition: A URN is a type of URI that identifies a resource by name within a specific namespace,
rather than by its location.
Key Points:
• URNs are used for resources that are not necessarily tied to a specific location.
• They provide a way to identify resources in a persistent manner.
Example:
• A URN could be: urn:isbn:0451450523
• This identifies a book by its ISBN number, which is a unique identifier.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Diagram:
+---------------------+
| URN |
+---------------------+
| Namespace: isbn |
| Identifier: 0451450523 |
+---------------------+

Summary Flow
To summarize the relationship between URI, URL, and URN, you can use the following flow:

+---------------------+
| URI |
+---------------------+
| |
| +--------------+ |
| | URL | |
| +--------------+ |
| |
| +--------------+ |
| | URN | |
| +--------------+ |
+---------------------+

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Endpoint:
1. Endpoints are the https address, and are used to make a request to get or send data
It is the URL which will accept the web services.
2. Basically endpoint is the address of the application to which the source application wants to
communicate.
Resource:
1. Resource is simply a data in Web Application
2. In REST, the primary data representation is called resource.
3. A resource can be a singleton or a collection.
Example:
“Customers” is a collection resource and “customer” is a singleton resource (in a
banking domain).
We can identify “customers” collection resource using the URI “/customers“.
We can identify a single “customer” resource using the URI “/customers/{customerId}“.
4. A resource may contain sub-collection resources also.
Example:
sub-collection resource “accounts” of a particular “customer” can be identified using the
URN “/customers/{customerId}/accounts” (in a banking domain).
Similarly, a singleton resource “account” inside the sub-collection resource “accounts”
can be identified as follows: “/customers/{customerId}/accounts/{accountId}“.

HTTP Methods:
1. GET: [Retrieve information about the REST API resource.]
1. Use GET requests to retrieve resource information only – and not modify it in any
way. As GET requests do not change the resource’s state, these are said to be safe
methods.
2. Additionally, GET APIs should be idempotent. Making multiple identical requests
must produce the same result every time until another API (POST or PUT) has
changed the state of the resource on the server.
2. POST: Create a REST API resource
1. POST methods are used to create a new resource into the collection of resources.
2. Please note that POST is neither safe nor idempotent, and invoking two identical
POST requests will result in two different resources containing the same information
(except resource ids).
3. POST is used to send data to a server to create/update a resource.
4. The data sent to the server with POST is stored in the request body of the HTTP
request
5. POST requests do not remain in the browser history
6. POST requests cannot be bookmarked
7. POST requests have no restrictions on data length
3. PUT: Update a REST API resource
1. Use PUT APIs primarily to update an existing resource entirely. If the resource does
not exist, then API may decide to create a new resource or not
2. The PUT method is generally called when we need to change a single resource.
3. PUT is used to send data to a server to create/update a resource.

4. DELETE: Delete a REST API resource or related

5. PATCH: Partially update a REST API resource.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

1. PATCH request method applies partial modifications to a resource.


2. If you only need to update one field for the resource, you may want to use
the PATCH method.
Idempotent
Idempotent implies that a certain operation can be applied many times, without changing the result.
Essentially, it is like multiplying a number by zero. No matter how many times you multiply a number,
the result is still zero.

Difference between PUT and POST

POST PUT
1. PUT methods are used to create/update a new
resource into the collection of resources. But PUT
methods primarily to update an existing resource
1. POST methods are used to create/update a new entirely. If the resource exist, then PUT API update
resource into the collection of resources. But POST the resource, else If the resource does not exist, then
methods primarily use for CREATE operations. API may decide to create a new resource or not
2. The POST method is known to be non-
idempotent. That means, if you retry the request 2. The PUT method is known to be idempotent. That
multiple times, you will end up having multiple is, calling the same PUT request multiple times will
resources with different URIs. always produce the same result.

Difference between PUT and PATCH

PUT PATCH
1. APIs primarily to update an existing resource 1. PATCH request method applies partial
entirely. . If the resource exist, then PUT API update modifications to a resource. If you only need to
the resource, or If the resource does not exist, then update one field for the resource, you may want to
API may decide to create a new resource or not use the PATCH method.
2. The PATCH method is known to be non-
2. The PUT method is known to be idempotent.. idempotent. That means, if you retry the request
That is, calling the same PUT request multiple times multiple times, you will end up having multiple
will always produce the same result. resources with different URIs.
3. Whereas, the PATCH method has comparatively
3. The PUT method has high bandwidth. low bandwidth.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Different types Authorizations in ServiceNow

Basic Authentication:
Basic authentication is the simplest form of authentication which requires only user name and
password to authenticate and start communication with other systems.
OAuth 2.0:
OAuth 2.0 is the modern form of authentication where IDP provides the token based access
instead of user credentials which additional security parameters like expiry date of token and
limit to only required application/data.

REST API Terms:

Endpoint:
1. Endpoints are the https address, and are used to make a request to get or send data
It is the URL which will accept the web services.
2. Basically endpoint is the address of the application to which the source application wants to
communicate.
Methods:
1. Methods tell that what source is doing for target instance.
2. Methods are used to perform CURD operations.
3. Methods are types of request like GET, POST,PUT, DELETE or PATCH

Authentication/Authorization details:
1. How the API will be authenticated. Example: Username/Password, Token...etc.
2. To communicate source application to the target application, we need entry pass, means we
need some key or credentials.
3. REST message HTTP methods below authentication types:
a. Basic authentication
b. Mutual (two-way authentication)
c. OAuth 2.0

Content/Request Body: The information which sent along with REST API.
Usually, it is sent with POST and PUT.

Content Type/Headers: The format of payload. Example: JSON, XML...etc.

Header: HTTP headers let the client and the server pass additional information with HTTP request or
response. Example: Accept, Authorization...etc

REST communication flow


Request Response
1. URI 1. Response Body
2. HTTP Method 2. Http Response code
3. Header
4. Request Body

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Response:
The ServiceNow API response consists of:
1. HTTP Response Status code
2. Response headers
3. Response body

HTTP Status Codes:


1. 1xx: Informational
2. 2xx: Success
3. 3xx: Redirection
4. 4xx: Client Error
5. 5xx: Server Error

Response Headers:
The Headers section shows the returned headers and their values

Response Body:
The response body is the data object returned by the ServiceNow web service provider.
The response body varies depending on the selected API.

APIs available in ServiceNow


1. Table API
2. Attachment API
3. Email API
4. Import set API

REST API Explorer:


REST API Explorer is an application to construct and test API request to a ServiceNow instance.

Request Parameters
1. Path parameters:
The list of path parameters depends on the endpoint URL.
Path parameters are enclosed in curly braces in the endpoint URL.
The values set in the path parameter field are substituted into the endpoint URL
when a request is sent.
2. Query parameters:
Request parameters are added to the endpoint URL by the REST API Explorer
when the request is sent.
The query parameters are specific to the selected API method.
3. Request headers
Request headers define the format of the Request and Response.

4. Request Body: A Request Body refers to the data that is sent to the server as part of an HTTP request. This is
typically used in POST, PUT, or PATCH requests, where the client needs to send data to the server to create or
update a resource.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

The Request Body can contain various types of data, including:

1. JSON (JavaScript Object Notation): A common format for sending structured data. For example:
{
"name": "John Doe",
"email": "[email protected]"
}
2. XML (eXtensible Markup Language): Another format for structured data, though less common than JSON in
modern APIs.
<user>
<name>John Doe</name>
<email>[email protected]</email>
</user>
3. Form Data: Often used in web forms, where data is sent as key-value pairs. This can be sent as application/x-
www-form-urlencoded or multipart/form-data.
4. Plain Text: Sometimes, simple text data is sent without any specific structure.

Inbound Integration:

Inbound means that other applications make calls to ServiceNow's REST API to get information from SN,
or create/update records.
Use case:
Through REST integration we will create record in ServiceNow instance from any other tool.

Creating a record through another ServiceNow instance


Steps:
1. Type Web services in left navigator
2. Goto Inbound
3. Click “Create New”
4. Fill the required values
5. Get some fields “Web Service Fields”, what are fields information we need from 3rd party
tool
6. Click on “Create”
7. Then redirect “Table Transform Map”
8. Then map the fields using “Auto Map Matching fields/Mapping Assists”
9. Then update the “Table Transform Map”.
10. And check in Web services in left navigator, we can find the inbound integration
11. Open it and we have option called “Explore REST API” under related links. To test the
integration.

Adding Security to Inbound Requests:


1. Create a user specifically for inbound requests.
2. Disallow web services to tables
3. Create CORS rules

Creating a record through 3rd Party instance:


Required information:
©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in
©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

1. HTTP method
2. Endpoint URL
3. Authorization
4. Provide the “Headers”
5. Enter body details in Json format

Outbound Integration:

Outbound means that ServiceNow makes calls to other applications' REST API to get information from
the other application or create/update records.
Use case: ServiceNow to 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).
Solution:
This use is implemented through Outbound REST message and Business rule.
Outbound REST message contains required information such endpoint URL, request body and
authorization details and through business rule we are going to trigger the particular rest
message, So that the incident will create in target instance.

Required things to do Integration:


Endpoints
Methods
Request body
Headers (Content Type)
Authorization Details
Steps:
ServiceNow Target Application Instance:
1. Goto REST API Explorer
2. Enter below details
a. Namespace
b. API Name
Note: in ServiceNow widely used APIs are “Table API” or “import set API”
c. API Version
d. Select HTTP method
e. Select the table in “Path parameters” as per requirement.
f. Select Request headers
g. Then enter Request body

In service we need credentials (Username and Password). Source instance need credentials of target
instance user. For that we need to create user with rest_service role and share those details with source
instance.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

ServiceNow Source application Instance:

1. Select REST message [System Web Services → Outbound → REST message]


2. Click “New”
3. Enter below details
a. Name
b. Endpoint
c. Authentication details
d. And “Save”. Once save HTTP methods will appear with “Default GET”
e. Click “HTTP Request” and create new HTTP method by passing mandatory details
f. Authentication for HTTP method will inherit from parent, So no need fill it again.
g. Then save the HTTP method.
h. Once HTTP method saved it, Under HTTP Request we have HTTP Query parameters.
Here we have to provide the request body.
i. And provide the request body details dynamically, in key value pair
Example:
{
“caller_id”:”${caller}
}
To populate these values dynamically need to write business rule
4. Create business rule to trigger
a. Create new business rule
b. Enter when to run details
c. In Advanced tab write script to in Target instance
Var req = new sn_ws.RestMessageV2(‘Rest Message’,’Name’); //These parameter
details from HTTP method in Source application instance.

ServiceNow to Jira Integration [Outbound]

1. What we need to integrate


ServiceNow:
Which module needs to be integrate: Agile Development
Trigger Condition:
Outbound REST Message
Jira:
Endpoint
Authentication
Resources
Fields
Payload
Method
2. Get Authentication details from JIRA
[Create authentication token in JIRA]
I. Goto the “Settings” → Personal Settings → Atlassian account settings

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

II. Click on “Security”

III. Under API token click “Create and manage API tokens”

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

IV. Click “Create API token”, then it will ask for “Label” and click “Create”

V. It will create token and copy it

VI. Now JIRA token is created, as below


Token:
ATATT3xFfGF0TImb89VZ_qdM8n1Co38t8XIPX2VTT9Aty25np9s_frBWdwguGMry7y0ceVpdjUGVNNjv7q
7jFQYvFBQUcwqudY7ndyE1j_QWebD9rIlVv1o4zYQd-0o95YlIuL4Ct701bnxroIBNK-
Ot2jYMTkzDN8ay8tcewZHbDQTxGI7yDag=E3CB3A77

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

3. Setting POST connection, in Outbound rest message


Use case1: Create JIRA record when story is created in ServiceNow
Goto → System Web Services →Outbound →REST Message

Endpoint: https://sagaras400.atlassian.net/rest/api/3

Authentication: Basic Auth

Then “Submit”

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

After submission the rest message by providing the endpoint and authentication, DefaultGET
method create in HTTP methods.

Enter “Headers” in HTTP Request tab and save the form

Then create new HTTP method as requirement


Here i am using POST method to create ticket/issue in JIRA when incident is created in
ServiceNow.
We need to give Name, HTTP method and endpoint URL. Authentication is inherit from parent, if
not we need to provide the authentication details

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

In the HTTP method also we need to provide the HTTP header details under HTTP request.

To test, provide the test code in “Content” in HTTP Query parameters

And click “Test” in Related Links

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Once test is successful, the result shown as below

Check in JIRA, new ticket will create below

4. To automate the process we need to write “Business rule” to trigger the Outbound REST
message.
Business rule condition is below
When: async and Insert

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Static code:

(function executeRule(current, previous /*null when async*/ ) {

var req_boby = "{\"fields\":{\"project\":{\"key\":\"JIR\"},\"summary\":\"Creating JIRA


ticket using business rule.\",\"issuetype\": {\"name\": \"Task\"}}}";

var request = new sn_ws.RESTMessageV2('Snow_to_JIRA_Integration', 'CreateIncident');


request.setEndpoint('https://sagaras400.atlassian.net/rest/api/3/issue');
request.setHttpMethod('POST');
request.setRequestBody(req_boby);

request.setBasicAuth('[email protected]',
'ATATT3xFfGF0TImb89VZ_qdM8n1Co38t8XIPX2VTT9Aty25np9s_frBWdwguGMry7y0ceVpdjUGV
NNjv7q7jFQYvFBQUcwqudY7ndyE1j_QWebD9rIlVv1o4zYQd-0o95YlIuL4Ct701bnxroIBNK-
Ot2jYMTkzDN8ay8tcewZHbDQTxGI7yDag=E3CB3A77');

request.setRequestHeader('Accept', "application/json");
request.setRequestHeader("Content-Type", "application/json");

var response = request.execute();


gs.log(response.getBody());

})(current, previous);

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Dynamic Code:

(function executeRule(current, previous /*null when async*/ ) {

var req_boby = "{\"fields\":{\"project\":{\"key\":\"JIR\"},\"summary\":" + "\"" +


current.short_description + "\",\"issuetype\": {\"name\": \"Task\"}}}";

var request = new sn_ws.RESTMessageV2('Snow_to_JIRA_Integration', 'CreateIncident');


request.setEndpoint('https://sagaras400.atlassian.net/rest/api/3/issue');
request.setHttpMethod('POST');
request.setRequestBody(req_boby);

request.setBasicAuth('[email protected]',
'ATATT3xFfGF0TImb89VZ_qdM8n1Co38t8XIPX2VTT9Aty25np9s_frBWdwguGMry7y0ceVpdjUGV
NNjv7q7jFQYvFBQUcwqudY7ndyE1j_QWebD9rIlVv1o4zYQd-0o95YlIuL4Ct701bnxroIBNK-
Ot2jYMTkzDN8ay8tcewZHbDQTxGI7yDag=E3CB3A77');

request.setRequestHeader('Accept', "application/json");
request.setRequestHeader("Content-Type", "application/json");

var response = request.execute();


gs.log(response.getBody());

})(current, previous);

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Check System logs

Finally check whether ticket is created in JIRA or not.

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in


©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

Bi-directional Webhook:
This has 2 modules:

• Jira Webhook Registries (these are used to assign a token and API path. We need to generate a call
back URL from here and provide it in Jira)
• Jira Webhook Routing Policies(these triggers the sub flows based on the conditions specified)

Note:

• ServiceNow provides a default routing policy which needs to be modified according to the requirement.

• Jira Spoke provides a default sub flow to process the Webhook events

Integration Steps:

Step -1: Setup Credential in ServiceNow

• In ServiceNow Instance, Navigate to Integration Hub > Credentials


• Click on “Jira” the entry created by the spoke. Provide the username and for the password, go back to
Jira and in Account Setting> Security> Create and Manage API token>Create API token
• Give a label and click on “Create” and “Copy” the token.
• Switch back to ServiceNow and paste this token in “Password” field and update this record.

Credentials has been setup


Step-2: Setup Connection in ServiceNow

• In ServiceNow Instance, Navigate to Integration Hub > Connections


• Click on “New” and “HTTP(s) connection”
• Provide a random Name in the “Name” field. Select the credential that we have selected in step-1 in
“credential” column.
• Connection Alias is referencing the Jira spoke. So select the Jira spoke in this column.
• Connection URL is the hostname of the Jira application.
• Click on “Submit”

Step-3: Check Connection and Credential Aliases

• In ServiceNow Instance, Navigate to Integration Hub > Connection & Credential Aliases.
• Click on “Jira” and check that credentials and connections are interconnected with each other.

Step-4: Create a Flow Designer

• In ServiceNow Instance, Navigate to Flow Designer > Designer


• Create a new Flow-Give a name and Submit
• In the trigger, create a trigger condition like when this Jira integration needs to be triggered.
• In the next step – Actions, Create a new action- Search for “issue or Jira” and click on “Create an
Issue”
• Provide Project Key, Issue Type and Summary, Click on “Done”
• For correlating these two, Jira provides back some parameters. Here we can use Issue ID and map
that to the record(incident or task etc..)
• For mapping the Jira Parameters to ServiceNow record, as the next step in Flow Designer, create an
other action “Update Record” and map the respective fields or add the parameters to the worknotes
etc.
©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in
©️HACKNOW Call/WhatsApp: +91 8984988593 https://hacknow.co.in

So Jira Setup is now


doneTest this
Step-5: Make this Bidirectional

• To make this Bi-Directional, we will create a webhook in ServiceNow.


• For creating a webhook, navigate to Jira Webhooks> Jira Webhook Registries and click on “New”
• Provide a random name in “name “Column and Select the built-in token i.e. Jira Token in the “Token”
column.
• So next thing is to get the callback URL for Jira to talk to ServiceNow.
• To do this, go back to webhook registry that we have created and click on “callback URL”. Copy the
URL from the information box.
• Now go back to Jira and open General Configuration and open Webhooks.
• Create a new Webhook in Jira Application (Specify random name and paste the URL copied from
SNOW into the URL field). Also please check when the issue is update checkbox. And click on
“Create”
• Now go back to ServiceNow instance and create a sub flow in flow designer.
• There is a default sub flow “Process Jira Webhook”. Make a copy of this sub flow
• In the sub flow, create an action “Lookup up Record” and find the incident where correlation id is
issueID
• Create another action for updating the record. For example, update the work notes with the
resolutionor description etc. sent from Jira.
• Now we are going to tell webhook which sub flow to be called

Step-6: Create Jira Webhook Routing policies

• There is a OOB decision. Update this with the sub flow that we have created.

https://www.servicenow.com/community/now-platform-articles/integration-with-jira-using-jira-
spoke/ta-p/2323402

©️HACKNOW Call/WhatsApp : +91 8984988593 https://hacknow.co.in

You might also like