0% found this document useful (0 votes)
47 views11 pages

SERVICENOW REST API Integration Part 2 by Revanth Karra 1729537731

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)
47 views11 pages

SERVICENOW REST API Integration Part 2 by Revanth Karra 1729537731

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/ 11

SERVICENOW

REST INTEGRATION
Part 2
REST API EXPLORER
1

SERVICENOW: REST API Explorer


Overview of ServiceNow as a Web Service Provider
ServiceNow is not just a tool for managing IT Services; it is also a powerful platform that
allows external systems (3rd party) to connect with it through web services like REST and
SOAP. This means other applications can talk to ServiceNow, share data, and work
together. It acts like a middleman, allowing different apps to exchange information
smoothly.

What is Web Service Provider?


A web service provider is like a store that offers its data and services to other systems
via web service protocols like REST or SOAP. These protocols allow secure,
standardized communication between different applications, enabling data exchange
and process automation (makes it easy for different apps to send and receive
information without human involvement)

Why ServiceNow as a Web Service Provider?


Here’s why companies like to use ServiceNow for this purpose:

• It helps to automate work between different apps, saving time.


• ServiceNow can easily connect with old (legacy) systems as well as modern
ones.
• It simplifies how businesses share and sync data between different departments
or with external partners.

By Serving as a web service provider, ServiceNow allows companies to use its features
and data to power other tools, reducing manual work and ensuing everything works
smoothly.

REVANTH KARRA 1
2

Use Cases of ServiceNow Web Services:


• Automating Incident Management: A system outside ServiceNow (like a
customer service app) can send information about a problem directly into
ServiceNow. The system then logs the issue and assigns it to the right team
without anyone needing to enter the data manually.
• Syncing Data Across Platforms: An HR system could automatically update
employee details in ServiceNow, making sure the records are always correct and
consistent.
• Creating Reports and Analysing Data: ServiceNow can share data with
reporting tools outside the systems, allowing businesses to run advanced
analyses and make better decisions.

By acting as a web service provider, ServiceNow helps businesses connect their apps
and data, making everyday operations easier and faster.

Interacting with ServiceNow via REST API: How Third-


Party Applications Communicate
When a third-party application (which means any external app or system outside of
ServiceNow) wants to communicate with ServiceNow, it uses something called a REST
API. Think of it like sending a message or making a request to a server (in this case,
ServiceNow) and getting a response back. This is how apps talk to each other without
any human involvement.

Here’s how the process works:

1. Making a Request: The third-party app sends a request to ServiceNow. This


request could be asking to get data (like a list of incidents), create something
new (like a new ticket), or update something (like changing a record).

2. Authentication: Before ServiceNow allows the request to go through, it needs to


make sure that the app sending the request is allowed to do so. It checks this
through something called authentication. This is like checking an ID to make
sure the person trying to get in is allowed access. This could be done using a
simple username and password (basic authentication) or more secure methods
like OAuth 2.0.

3. Endpoint: The request is sent to a specific endpoint. An endpoint is just an


address in ServiceNow where the request is sent. For example, if the app wants

REVANTH KARRA 2
3

to look up all the incidents, it sends the request to the “incident” endpoint in
ServiceNow’s API.

4. Getting a Response: Once ServiceNow processes the request, it sends a


response back to the app. This response can contain the data requested or a
message saying whether the operation was successful (like "Ticket created
successfully") or failed (like "Error: Incorrect request format").

This back-and-forth communication allows companies to connect their external apps


with ServiceNow, ensuring data flows smoothly between systems.

Key ServiceNow APIs


ServiceNow provides several APIs to help with different tasks. Here are some of the
most commonly used ones:

• Table API: This is the main tool for working with data in ServiceNow. It lets you
create, read (get data), update, or delete records in any table in ServiceNow. For
example, you can use it to get a list of all open tickets or update a specific
record.

• Attachment API: This API helps manage files attached to records in ServiceNow.
You can upload, download, or delete attachments, which is useful if you need to
share documents or files with other systems.

• Email API: The Email API allows you to send emails directly from ServiceNow. It’s
helpful for sending notifications, alerts, or updates when something important
happens in the system (like when a new ticket is created).

• Aggregate API: This API is used when you need summary information, like
counting how many incidents are open or finding the average time it takes to
close tickets. It’s perfect for creating reports or getting a quick overview of data.

These APIs are like tools that help you interact with different parts of ServiceNow and
perform various tasks.

REVANTH KARRA 3
4

Demonstration of Web Service REST API

API works on Client and Server Architecture. Here, when Client sends a request to a
Server and Server responds back to the client. Here we need to know, when Server APIs
work using something called Client-Server Architecture. This means:

• The client sends a request to the server, asking for some information or to
perform a task.

• The server processes this request and sends back a response with the
information or the result of the task.

Understanding the Server's Response

When the server replies, it’s important to know what the response contains and how it’s
formatted:

• Response Format: The server usually sends its response in a format called
JSON (JavaScript Object Notation). JSON is widely used because it is simple and
easy for both humans and machines to read and understand.

• Response Contents: The response from the server may contain different types
of information, including:

o The data you requested (for example, details about a user, or a list of
products).

REVANTH KARRA 4
5

o Status codes that tell you if the request was successful (e.g., 200 OK
means everything worked, while 404 Not Found means the server
couldn’t find what you asked for).

o Any error messages, if there were problems with the request (e.g.,
missing information or incorrect input).

How the Client Uses the Response

When the client receives the server’s response in JSON format, it can read and process
the data to use in the application. For example, it can display the information to the user
or store it in a database.

Summary

1. The client sends a request to the server.

2. The server processes the request and sends back a response in JSON format.

3. The client reads the response, which includes the requested data, status codes,
or error messages.

This process helps applications exchange information in a fast and reliable way.

First, let us discuss about REQUEST.

Note: It is important to know, that REQUEST is made up of 4 things:

1. End Point
https://xyzdomainname.com/api/now/tablename
2. HTTP methods
a. GET: Use to Retrieve the resource
b. POST: Use to create resource
c. PUT: Use to update or replace resources
d. PATCH: Use for partial update or replace resources
e. DELETE: Use to delete resource

Note: These are the methods that we use in REST API. Which is basically used to
perform CRUD Operations. CRUD Operations means CREATE, READ, UPDATE
and DELETE

3. The Header
“Content-Type:application/JSON”
4. The body
{“number”:”123” “description”:”demo of rest api”}

REVANTH KARRA 5
6

Let us assume, when the Client sends “GET” request to a Server to retrieve information.

Example:

In the snippet above, the client is sending an HTTP GET request to a server in order to
retrieve specific information.

• The HTTP Method (GET) specifies the type of request the client is making to the
server.

• The server address (in this case, xyztest.com) is where the request is being sent.

• The final part of the URL, /User/1/Manager, represents the resource the client is
attempting to retrieve from the server. This resource could, for example, be
information related to the manager of a specific user (identified by /User/1).

In this scenario, the client is likely trying to retrieve the name of the manager for the user
with ID 1.

REVANTH KARRA 6
7

Let’s get Started!!!


Exploring REST API Explorer
The REST API Explorer is a tool in ServiceNow that helps you work with APIs without
needing to write complex code. Think of it as a helpful assistant that guides you in
creating, testing, and troubleshooting API requests. It makes interacting with
ServiceNow’s REST APIs simple and more efficient, especially for beginners or those
who want to quickly check how an API works.

Navigating the REST API Explorer


To start using the REST API Explorer in ServiceNow:

1. First, we need to open ServiceNow, and in the navigation bar, type “REST API
Explorer”.

2. Click on the REST API Explorer from the menu that appears.
3. Now, we need to click Explore on the REST API Explorer interface.

4. Let’s keep everything as default.

REVANTH KARRA 7
8

5. For this demo, let’s use POST Method by clicking Create a record (POST)

6. As we discussed earlier, we need to have Server Address or End Point, HTTP Method,
The Head and The Body for a REQUEST.
7. Let’s check one by one, this is the Server Address or End Point and HTTP Method.

8. The Header and

9. The Body.

10. Now let’s fill all the required fields in the Request Body.

11. And Click Send to send the Request.

REVANTH KARRA 8
9

12. Now, let’s discuss about the Response, we get for this Request.
13. If a New Record is created successfully then we get a Status code as 201 Created

14. Along with Response, we get Response Body.

15. Let us verify this newly created record by typing “incident.LIST” in the navigation
bar.
16. As we can see a record INC00077 got created successfully.

17. So, what if the record is not created? What are the corresponding status codes we
get, when a POST request might fail to create a record:
• 400 Bad Request – The request payload (body) is malformed or missing
required fields.
• 401 Unauthorized – The client is not authenticated or provided incorrect
credentials.
• 403 Forbidden – The use or Integration account does not have the required
permissions to create a record in the target table.
• 404 Not Found – API Endpoint or resource (table) doesn’t exist.

REVANTH KARRA 9
10

• 500 Internal Server Error – There is an issue on the ServiceNow server (e.g.,
a script or database error) that is preventing the record from being created.

REVANTH KARRA 10

You might also like