In order to call the API of an application that is hosted on an API Connect collective, you need to set the host
header and specify the correct URL before invoking the API of the application.
Before you begin
Important: IBM® API
Connect
Micro Gateway is deprecated in IBM API
Connect Version 5.0.8 in favor of DataPower® Gateway. From 1 April 2020, Micro Gateway, and associated toolkit CLI commands, will no longer
be supported. Existing users can migrate their API definitions to IBM
DataPower Gateways. For information on supported API policies, see
Built-in
policies.
To
complete this task you must:
Procedure
To set the host headers for an invocation of your application, complete the following
steps:
-
Click APIs.
The APIs tab opens.
-
If you have not previously pinned the UI navigation pane then
click the Navigate to icon
.
The
API Manager UI navigation pane opens. To pin the
UI navigation pane, click the
Pin menu icon

.
-
Click Drafts in the UI navigation pane, and then click APIs.
The APIs tab opens.
-
Click the API that you want to use to call the application endpoint. For information on
creating REST API definitions, see Composing a REST API definition.
-
Click the Assemble tab.
-
If you have not already specified which type of gateway you want to use the API with, select
DataPower Gateway or Micro Gateway as
appropriate.
-
From the palette, click invoke and drag it across to the canvas. Place
it at the point in the assembly that you want to invoke the endpoint.
-
Click your newly created invoke policy and configure its properties in
the property sheet.
-
From the palette, click set-variable and drag it across to the canvas.
Place it immediately before your invoke policy from step 7.
-
Click your newly created set-variable policy to open the property
sheet.
- Optional:
In the Title field, enter Set Host Header
-
Click + Action.
-
Configure the properties of the action according to the following table:
Table 1. Set action
| Property |
Value |
| Action |
Set |
| Set |
message.headers.host |
| Type |
String |
| Value |
Host_Header.$(api.org.name) |
where
Host_Header is the value that you recorded when you published your
application.
-
Click the Save icon
to save your changes.
Results
Your API definition can now call your application's endpoint correctly.