IBM® Integration Bus provides a RESTRequest node, which enables
you to interact with external REST APIs.
About this task
You can use a RESTRequest node in a message
flow to issue synchronous requests to external REST APIs. The RESTRequest node uses an imported
Swagger document in either JSON or YAML format, which you can import
from the toolkit workspace, your file system, or from a URL.
If
you have created a REST API from scratch in the IBM Integration Toolkit, a Swagger document was
created for you, which you can now import and use with the RESTRequest node.
For
more information about creating REST APIs, see Creating a REST API.
For more information about using a RESTRequest node, see RESTRequest node.
Procedure
Import a Swagger document and configure a RESTRequest node by completing
the following steps:
- Create a message flow to include your RESTRequest node.
- Configure the RESTRequest node
to use an imported Swagger document that contains the operation that
you want to invoke, by using one of the following methods:
- Drag and drop an operation from the REST APIs Catalog onto
the message flow canvas or onto a connection between two existing
nodes in the message flow. A RESTRequest node is created
automatically and configured to use the selected operation. If the
operation is dropped onto a connection between two existing nodes,
the RESTRequest is inserted
into the flow between the two existing nodes.
A REST
APIs Catalog folder in each project in the Navigator contains
a list of all the REST APIs that are available in the project for
use with RESTRequest and RESTAsyncRequest nodes. Each
REST API folder contains a list of all the available operations in
the REST API.
- Drag and drop a RESTRequest node
from the palette onto the message flow canvas.
When you place the RESTRequest node onto the canvas,
a wizard guides you through choosing the REST API and the operation
that you want to invoke. You can select an operation from the set
of operations in the imported Swagger document, and specify parameter
values as node properties, using XPath or ESQL expressions to select
data from the input message tree.
- Use the Invoke an operation in a REST API page
in the wizard to specify the location of the Swagger document that
contains the operation that you want to use:
- Select a Swagger document from a referenced project
or from a file system
Select this option to display
a window in which you can either specify either a location in your
file system, or select a Swagger document from a referenced project.
If you select a Swagger document from your file system, it is copied
into the project that contains your RESTRequest node.
If
you want to use a Swagger document from a shared library that is not
referenced, you must reference the shared library first, and then
add the RESTRequest node.
- Retrieve a Swagger document from a URL using HTTP or
HTTPS
Select this option to display a window in which
you can specify a URL to a Swagger document. This Swagger document
is downloaded and stored in the project containing the RESTRequest node.
- Configure the REST request node manually
Select
this option to close the wizard without making any changes to the RESTRequest node. You can then
optionally drag and drop an operation from the REST APIs
Catalog in the Navigation onto the RESTRequest node in the message
flow, and it is configured automatically to use that operation.
- If you selected either Select a Swagger document from
a referenced project or from a file system or Retrieve
a Swagger document from a URL using HTTP or HTTPS in the
previous step, a window is displayed in which you can select an operation
to invoke in the REST API. Select the required operation and click Finish.
The RESTRequest node is
automatically configured to use the selected operation.
- Drag and drop a RESTRequest node
from the palette onto a connection between two existing nodes in your
message flow. The RESTRequest node
is inserted into the flow between the two existing nodes, and the
configuration wizard opens, enabling you to configure the new node
with the required REST API operation.
- Configure the remaining properties of your RESTRequest node.
- Configure the security credentials for interacting with
the REST API, by using the mqsisetdbparms command command.