Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 13. Connect to REST APIs

In an integration, to connect to a REST API, you must have created a connector for that API by uploading an OpenAPI schema that describes the API. See Integrating Applications with Fuse Online, Adding REST API client connectors.

When a connector for the REST API you want to connect to is available in Fuse Online, the steps for connecting to that REST API are:

13.1. Register Fuse Online as an API client

Before Fuse Online creates an API client connector, it prompts you to indicate the API’s security requirements. For APIs that use the OAuth protocol, when Fuse Online creates the connector it also adds an entry for the API to the Fuse Online Settings page. This is where you provide the API client ID and the API client secret that authorize Fuse Online to access the API.

If the API you want to connect to does not use OAuth, skip this section and see Create a REST API connection.

Prerequisite

You must know the URL for the OAuth custom application setting page for the REST API that you want to connect to.

Procedure

  1. In Fuse Online:

    1. On the Settings page, near the top, to the right of the callback URL, click Copy Callback URL to copy the callback URL for your Fuse Online environment to the clipboard. You will need this URL later in this procedure.
    2. Look for the name of the API you want to connect to and click its Register button to display its client ID and client secret fields.
  2. In another browser window, you must register Fuse Online as an OAuth client of the API you want to connect to. The exact steps for doing this vary for each API service. Typically, the API service provides an OAuth custom application setting page. Go to that page and do the following:

    1. Provide the Fuse Online callback URL, which you copied at the beginning of this procedure.
    2. Respond to any other prompts that require your input.
    3. Obtain the client ID and client secret that the API service assigns to your Fuse Online environment.
  3. Return to the Fuse Online Settings page entry for the API service you are registering with and do the following:

    1. Paste the assigned client ID.
    2. Paste the assigned client secret.
    3. Click Save.

13.2. Create a An API client connection

In an integration, to connect to a REST API, create a connection to that REST API, which you can then add to any number of integrations.

Prerequisites

  • You created a connector for the REST API that you want to connect to.
  • If the REST API uses the OAuth protocol then you registered you Fuse Online environment as a client application that can access that REST API.

Procedure

  1. In Fuse Online, in the left panel, click Connections to display any available connections.
  2. In the upper right, click Create Connection to display available connectors.
  3. Click the connector for the API that you want to create a connection for.
  4. Respond to prompts for additional information. The definition of the API determines what Fuse Online prompts for. For example, for an API that uses HTTP Basic Authorization, Fuse Online prompts for the user name and password to use to access the API. For an API that uses OAuth, Fuse Online displays a button for you to click so that Fuse Online can verify its registration credentials for connecting to the API.
  5. In the Connection Name field, enter your choice of a name that helps you distinguish this connection from any other connections.
  6. In the Description field, optionally enter any information that is helpful to know about this connection.
  7. In the upper right, click Create to see that you can now choose the connection you created and add to an integration.

13.3. Add an API client connection to an integration

In an integration, to connect to a REST API, add a connection to that REST API to the integration.

In this release, in an integration, a connection to a REST API can be the finish connection or a middle connection. It cannot be the start connection.

Prerequisites

  • You created a connection to the REST API.
  • You are creating or editing an integration.
  • The integration already has its start connection.
  • Fuse Online is prompting you to select a finish connection or a connection that is not the start connection.

Procedure

  1. On the page that displays available connections, click the REST API connection that you want to add to the integration.
  2. Click the action that you want the connection to perform. The actions that are available are based on the resource operations specified in the OpenAPI file that was uploaded to Fuse Online and that describes the API you are connecting to.
  3. Depending on the action you select, enter any parameters that Fuse Online prompts for.
  4. Click Done.

Result

The connection appears in the integration flow in the location where you added it.