Integrating a REST Web Service That Returns JSON Data
  • 14 Oct 2021
  • 3 Minutes to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Integrating a REST Web Service That Returns JSON Data

  • Dark
    Light

Overview

The Decisions portal can integrate with web services that return JSON formatted data.
The steps for retrieving and using the JSON data are as follows:

  1. Integrate the service within the Decisions portal
  2. Create a Flow to make the service call and handle the results
  3. Generate a data type to deserialize the JSON data, so it is usable and introduces that type into the Flow.

In this example, a web service that retrieves the weather is integrated with the Decisions portal. An XML data type is generated against the web service's return data structure, and a Flow is created to make the service call and handle the results.

This method is deprecated. Please refer to the Using GET Method with REST Service Integration and Using POST Method with REST Service Integration articles to learn the new way to integrate with a REST Service introduced in versions 6.10.0.

Integrating the Web Service

  1. Log in to the portal (with an administrator account). 
  2. Navigate to System > Integrations > External Services.
  3. Select Add REST Service Integration
  4. In the Service Name field, type the name of the web service. 
  5. Then, in the Service URL field, paste in the URL. The URL will most likely contain variables to pass in; those will be moved to a new field after the following settings are established. For example purposes, use: https://slack.com/api/api.test.
  6. For this example, change the Service Input Method field value to Get
  7. Change Service Content Type to JSON.
  8. Select SAVE to complete setting up the RESTService Reference.
In other scenarios:
When the Service Input Method value is Post, a Data To Send field will add parameters for data to be passed in. If using this method: From the URL, cut the list of parameters, which starts after the question mark (?) in the URL. Paste that string into the Data to Send field and remove the question mark that starts the string.

2019-03-11_133153.PNG

Using the Web Service Call in a Flow

  1. Create a new Flow that will make the call to the web service and ingest the return data. 
  2. From the Designer Folder, select CREATE FLOW. 
  3. Name the new Flow and select OK.
  4. From the Steps panel, expand Integrations > All Integrations > Rest Service category and select the API Test component. 
  5. Select ADD to add it to the workspace.

    2019-03-11_133405.PNG

  6. The output of this web service call will be a string of serialized JSON data.
  7. To use the data returned in a more meaningful way, it is necessary to create a Data Structure.
  8. Save and close the Flow.

2019-03-11_133546.PNG

Create Data Structure From JSON

  1. From the Designer Folder, select CREATE DATATYPES/INTEGRATION > Create Types from JSON.

    2019-03-11_144213.PNG

  2. Paste in the structure when creating the data type. There is also the potential to upload the structure through a JSON file.
  3. Enter a name for the service in the JSON Structure Name field and upload a file for the structure or paste in the Data Structure. 
  4. In the list of recognized data types from the structure, select the desired types.
  5. Select SAVE STRUCTURE. 
    The Data Structure is generated for the JSON data, as well as components for deserializing and serializing that data.

    2019-03-11_135407.PNG

Deserialize JSON Data

  1. Next, introduce the Deserialization step into the Flow to break down the JSON string into meaningful data.
  2. From the Designer Projects Folder, open the Flow that contains the API Test service step.
  3. From the Steps panel, expand the Data > JSON category. 
  4. Drag and drop the JSON Deserializer step following the API Test step. 
  5. Connect the outcome paths, as pictured below.
  6. Select the JSON Deserializer step. 
  7. In the Properties panel under Input, change the mapping type for String to Deserialize to Select from Flow
  8. Choose Select from Flow in the Pick Data dialog and chose Done, and select Pick. This is the output from the API Test step.
  9. Expand the Data Explorer on the left side of the studio, notice how the deserialized output is available.

    2019-03-11_140128.PNG


Was this article helpful?