A hands-on walkthrough of the foundational tools and skills every ServiceNow developer needs to start building integrations.

6 minute read

This post is based on a training outline I put together in 2018 for junior ServiceNow developers. The goal is simple: take someone who’s comfortable writing GlideRecord scripts and get them making outbound REST calls, parsing responses, and understanding what’s happening at each layer.

No plugins, no store apps. Just the built-in tools that ship with every instance.

The Tools

Inside ServiceNow

You don’t need anything fancy to start making API calls from ServiceNow. These four things will get you through everything in this post:

  • REST Message: The point-and-click UI for defining outbound REST endpoints. Found under System Web Services > Outbound > REST Message. Good for setting up reusable integrations with named HTTP methods, variable substitution, and test capabilities built in.
  • RESTMessageV2: The server-side scripting API (sn_ws.RESTMessageV2). This is what you use when you need full control: dynamic URLs, custom headers, conditional logic, error handling. It can reference a REST Message record or be used standalone.
  • Xplore: A developer tool for running server-side scripts interactively. I recommend using Xplore in Global scope with gs.print for all the exercises below. If you don’t have Xplore installed, a background script or fix script will work fine.
  • Outbound HTTP Requests: The system log that captures everything leaving your instance. Found under System Logs > Outbound HTTP Requests. This is essential for debugging because it shows the full request/response, including headers, body, and status code.

On Your Local Machine

For testing APIs before you touch ServiceNow, use a REST client:

  • Postman: The most popular option. Good for building collections, saving requests, and sharing with your team.
  • Insomnia: A lighter alternative if you prefer something simpler.
  • Browser plugins: Tools like Advanced REST Client (ARC) work in a pinch for quick GET requests.

Pick one and get comfortable with it. You’ll use it constantly.

HTTP Fundamentals

Before writing any integration code, you need to be able to explain these three things. If someone asks you “what did that API call do?” you should be able to answer clearly.

HTTP Verbs

The verb tells the API what you want to do:

Verb Purpose Example
GET Retrieve data Fetch a list of incidents
POST Create something new Submit a new record
PUT Replace an existing resource Overwrite a record entirely
PATCH Partially update a resource Update one field on a record
DELETE Remove a resource Delete a record

For most ServiceNow integrations, you’ll spend 90% of your time with GET and POST.

HTTP Status Codes

The response code tells you what happened:

  • 2xx (Success): 200 OK means you got your data. 201 Created means the thing you submitted was created.
  • 3xx (Redirect): The resource moved. Usually handled automatically by your HTTP client.
  • 4xx (Client error): You did something wrong. 400 Bad Request means your payload is malformed. 401 Unauthorized means your credentials are wrong or missing. 404 Not Found means the endpoint doesn’t exist.
  • 5xx (Server error): The remote system broke. 500 Internal Server Error is the catch-all. Probably not your fault, but still your problem to handle.

Always check the status code before trying to parse the response body. A 200 with bad data is easier to debug than a 401 you never noticed.

Anatomy of an HTTP Request

Every HTTP request has these parts:

https://api.example.com:443/v2/data?format=json&limit=10
\___/   \_____________/ \_/ \______/ \___________________/
scheme       host       port  path      query string
  • URL: Where you’re sending the request (scheme + host + port + path).
  • Query string: Key-value pairs appended to the URL after ?. Used for filtering, pagination, format selection.
  • Headers: Metadata about the request. Common ones include Content-Type (what you’re sending), Accept (what you want back), and Authorization (who you are).
  • Body: The payload. Used with POST, PUT, and PATCH. Usually JSON.

Scripting Warm-Up

If any of these exercises feel unfamiliar, spend time here before moving on to API calls. Integration code is regular JavaScript with HTTP calls mixed in, so if you can’t manipulate arrays and objects confidently, the API part will be harder than it needs to be.

Try each exercise yourself before expanding the solution. Open Xplore, read the prompt, and write the code from scratch. You’ll learn more by struggling through it than by reading the answer. Getting stuck is fine; it means you found a gap worth filling.

Arrays

Create an array with a few values, loop through it, and log each value with its index.

Show solution
var fruits = ['Apple', 'Banana', 'Kiwi'];

for (var i = 0; i < fruits.length; i++) {
    gs.print(i + ': ' + fruits[i]);
}

Now add a new item to the array and loop again.

Show solution
fruits.push('Orange');

for (var i = 0; i < fruits.length; i++) {
    gs.print(i + ': ' + fruits[i]);
}

You should see all four items with correct index positions.

Objects and JSON

Create an object with a few properties, then convert it to a JSON string and log it.

Show solution
var fruit = {
    name: 'Apple',
    color: 'Red',
    count: 5
};

gs.print(JSON.stringify(fruit));

Now make the output readable with pretty-print indentation.

Show solution
gs.print(JSON.stringify(fruit, null, 2));

The third argument (2) adds indentation. Good for debugging, skip it in production payloads.

Parsing JSON Strings

Start with a raw JSON string, convert it into an object, then log individual properties from it.

Show solution
var jsonString = '{"name":"Banana","color":"Yellow","count":3}';
var obj = JSON.parse(jsonString);

gs.print(obj.name);   // Banana
gs.print(obj.color);  // Yellow

This is exactly what you’ll do with every API response: get a JSON string back, parse it into an object, then pull out the values you need.

Making Your First API Call

Now we’ll use a public API. No authentication required, just a GET request that returns JSON.

Step 1: Call it in your browser

Paste this URL into your browser:

https://api.coinmarketcap.com/v2/ticker/1/

You’ll see raw JSON. Look at the structure. Find where the data lives, what the keys are called, and what types the values are (string, number, nested object).

Step 2: Call it in Postman

Open Postman, create a new GET request with the same URL. Send it. You’ll get the same response with better formatting, plus headers, status code, and response time.

Step 3: Call it from the REST Message UI

In ServiceNow:

  1. Navigate to System Web Services > Outbound > REST Message
  2. Create a new REST Message with the endpoint URL
  3. Add an HTTP Method record (GET)
  4. Click Test to execute it

Check the response body and HTTP status. Then go to System Logs > Outbound HTTP Requests and find your request. Verify the full round-trip looks correct.

Step 4: Call it in pure code

Using sn_ws.RESTMessageV2, write a script in Xplore that makes a GET request to the same endpoint and logs the HTTP status code and response body. Give it a shot before looking at the answer. You have the class name and the endpoint; that’s enough to start.

Show solution
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('GET');
request.setEndpoint('https://api.coinmarketcap.com/v2/ticker/1/');

var response = request.execute();
var httpStatus = response.getStatusCode();
var body = response.getBody();

gs.print('Status: ' + httpStatus);
gs.print('Body: ' + body);

Step 5: Parse the response

Take your working code from Step 4 and extend it. Parse the JSON response body, then extract and log the cryptocurrency’s symbol and its USD price. You’ll need to navigate a nested object structure, so look at the raw JSON from Steps 1-2 to figure out the key path. Don’t peek until you’ve tried it.

Show solution
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('GET');
request.setEndpoint('https://api.coinmarketcap.com/v2/ticker/1/');

var response = request.execute();
var body = response.getBody();
var obj = JSON.parse(body);

var symbol = obj.data.symbol;
var price = obj.data.quotes.USD.price;

gs.print('Symbol: ' + symbol);
gs.print('Price: $' + price);

And that’s the whole flow. Outbound REST call, JSON parse, value extraction. The integrations you build from here (Azure, Slack, Jira, internal systems) all follow this same pattern with more authentication and error handling layered on top.

What’s Next

Once you’re comfortable with outbound GET requests, the next topics to tackle:

  • POST requests: Sending data to external systems (request body, Content-Type header)
  • Authentication: Basic auth, OAuth 2.0, API keys in headers
  • Error handling: What to do when the remote system returns a 4xx or 5xx
  • Inbound APIs: Exposing ServiceNow data via Scripted REST APIs so other systems can call you

Those are for another post. For now, make sure you can do everything above from memory.

– JarodM