Skip to main content

Bonus Exercise 3.1: Create an Integration Hub Action

Duration: 30 minutes

In this bonus exercise, we will use a real webservice API to update our list of airports which we previously imported via an excel spreadsheet. This will ensure that the locations all remain up to date with some additional data fields for tracking.

If you noticed in exercise 1, when we imported the Airports from the excel sheet, the Lat and Lon data is empty, we will fix that in this exercise.

caution

This session will require you to use a 3rd party API service to get data. Your personal data will be required to sign up to this service. If you are not comfortable with exposing this data, skip this exercise or let your instructor know.

  1. Go to https://airlabs.co/ and click Sign Up
  1. Fill in the relevant details to sign up for an account
  1. Verify your account with the email sent to the email address sent to your email account
  1. Sign in to your airlabs account on the next page
  1. Click Copy next to API Key
  1. Paste your copied API Key somewhere that you are able to retrieve later
  1. Click Documentation, then Airports
  1. Quickly read through this API documentation, notice that the API request has already been populated for you - We will rebuild this
  1. Navigate back to your main ServiceNow interface, and search and click Action Designer under All
  1. You are brought to the Flow Designer interface
  1. Click the New button on the top right, then click Action
  1. In the pop-up, enter Get Airport Details under Action name. For description, enter Calls the Airlabs API to retrieve airport details
  1. Click Submit
  1. Click Create Input
  1. Under Label, enter IATA Code, then press enter
  1. Click on the + icon in between Inputs and Error Evaluation on the left sidebar
  1. In the pop-up box, scroll down and click REST
  1. Change Connection to Define Connection Inline
  1. Copy this URL and paste it under Base URL:
https://airlabs.co/api/v9
tip

Use the copy button above to make sure you have the correct URL

  1. Enter /airports under Resource Path
  1. Click on the + icon for Query Parameters
  1. Enter api_key under Name, then paste your previously copied API Key under Value
  1. Click on the + icon for Query Parameters
  1. Enter iata_code under Name, then drag and drop the IATA Code data pill on the right sidebar onto the Value field
  1. Click on the + icon for Headers
  1. Enter User-Agent under Name, and XXXXXX under Value
  1. Your form should now look like this:
  1. Click Save at the top right
  1. Click Test at the top right
  1. Enter SIN under the IATA Code field, then click Run Test
  1. Click Your test has finished running. View the action execution details.
  1. The new tab shows every step of the execution so far. Expand Steps (towards the bottom of the screen) and scroll down to the line that shows Response Body
  1. Click on the corresponding value and copy the entire block of text
  1. Navigate back the the main Action Get Aiport Details tab
  1. Close the pop-up
  1. Click on the + icon on the left sidebar after REST step
  1. Scroll down and click JSON Parser
  1. Drag and drop the Response Body data pill from the right sidebar onto the Source data field
  1. Paste what you copied onto the main body
  1. Toggle the Structured Payload View
  1. Click Generate Target
  1. The Target on the right should be generated
  1. Here are all the steps in sequence:
  1. Click Outputs on the left sidebar
  1. Click Create Output
  1. In the new row, change Label to Output, Name to output and Type to Array.Object
  1. Click Exit Edit Mode
  1. On the right sidebar, expand root under JSON Parser Step
  1. Drag and drop the response data pill onto the Output Value field
  1. Click Publish on the top right
  1. Click Test
  1. Enter BKK and run test, then view execution details
  1. Ensure that the Output is defined, and when clicking on it you see a result similar to what is shown below

You've create an Integration Hub action! It will automatically integrate with the remote API to gather information about the airports. Now let's use it in a workflow.