[V5.0.2 or later]

Modifying the assembly to call an application endpoint hosted on a collective

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:

  1. Click APIs.
    The APIs tab opens.
  2. If you have not previously pinned the UI navigation pane then click the Navigate to icon The Navigate to icon.
    The API Manager UI navigation pane opens. To pin the UI navigation pane, click the Pin menu icon The Pin menu icon..
  3. Click Drafts in the UI navigation pane, and then click APIs.
    The APIs tab opens.
  4. 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.
  5. Click the Assemble tab.
  6. 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.
  7. 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.
  8. Click your newly created invoke policy and configure its properties in the property sheet.
    • DataPower Gateway onlyIf you want to invoke the endpoint directly, using the base path and Path names of the API definition you are working in, in the URL field, enter http://ODR-DYN$(request.path)$(request.search).
    • Micro Gateway onlyIf you want to invoke the endpoint directly, using the base path and Path names of the API definition you are working in, in the URL field, enter $(runtime-url)$(request.path)$(request.search).
    • If you want to invoke the endpoint from an API definition other than that which was created as part of a LoopBack project, or if you want to invoke the endpoint of a different application, enter its URL in the URL field.
      Note: If you are using a DataPower Gateway, you will still need to use http://ODR-DYN for the host section of the URL.
  9. From the palette, click set-variable and drag it across to the canvas. Place it immediately before your invoke policy from step 7.
  10. Click your newly created set-variable policy to open the property sheet.
  11. Optional: In the Title field, enter Set Host Header
  12. Click + Action.
  13. 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.
  14. Click the Save icon The Save icon. to save your changes.

Results

Your API definition can now call your application's endpoint correctly.