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.
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.
- Go to https://airlabs.co/ and click Sign Up
- Fill in the relevant details to sign up for an account
- Verify your account with the email sent to the email address sent to your email account
- Sign in to your airlabs account on the next page
- Click Copy next to API Key
- Paste your copied API Key somewhere that you are able to retrieve later
- Click Documentation, then Airports
- Quickly read through this API documentation, notice that the API request has already been populated for you - We will rebuild this
- Navigate back to your main ServiceNow interface, and search and click Action Designer under All
- You are brought to the Flow Designer interface
- Click the New button on the top right, then click Action
- In the pop-up, enter Get Airport Details under Action name. For description, enter Calls the Airlabs API to retrieve airport details
- Click Submit
- Click Create Input
- Under Label, enter IATA Code, then press enter
- Click on the + icon in between Inputs and Error Evaluation on the left sidebar
- In the pop-up box, scroll down and click REST
- Change Connection to Define Connection Inline
- Copy this URL and paste it under Base URL:
https://airlabs.co/api/v9
Use the copy button above to make sure you have the correct URL
- Enter /airports under Resource Path
- Click on the + icon for Query Parameters
- Enter api_key under Name, then paste your previously copied API Key under Value
- Click on the + icon for Query Parameters
- Enter iata_code under Name, then drag and drop the IATA Code data pill on the right sidebar onto the Value field
- Click on the + icon for Headers
- Enter User-Agent under Name, and XXXXXX under Value
- Your form should now look like this:
- Click Save at the top right
- Click Test at the top right
- Enter SIN under the IATA Code field, then click Run Test
- Click Your test has finished running. View the action execution details.
- 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
- Click on the corresponding value and copy the entire block of text
- Navigate back the the main Action Get Aiport Details tab
- Close the pop-up
- Click on the + icon on the left sidebar after REST step
- Scroll down and click JSON Parser
- Drag and drop the Response Body data pill from the right sidebar onto the Source data field
- Paste what you copied onto the main body
- Toggle the Structured Payload View
- Click Generate Target
- The Target on the right should be generated
- Here are all the steps in sequence:
- Click Outputs on the left sidebar
- Click Create Output
- In the new row, change Label to Output, Name to output and Type to Array.Object
- Click Exit Edit Mode
- On the right sidebar, expand root under JSON Parser Step
- Drag and drop the response data pill onto the Output Value field
- Click Publish on the top right
- Click Test
- Enter BKK and run test, then view execution details
- 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.