Calling an API

When you have a selected a Plan and you begin coding your application, you must retrieve the operation URL to call the API.

About this task

Be aware of the following points when you call APIs in IBM® API Connect:
  • In the HTTP response message for status code 200 the reason phrase is replaced with OK.
  • API error messages are displayed in English only.

Procedure

To retrieve the operation URL, complete the following steps:

  1. Click API Products, then click API under the name of the Product that contains the API you want to work with.
  2. Click the API that you want to work with.
    The API overview page opens.
  3. Under the API Operations heading, copy the URL.
    This is the URL that the application calls, and its structure is defined:
    Type of API URL
    REST APIs https://host/org/catalog/api/operation
    SOAP APIs https://host/org/catalog/api for all operations in the WSDL.
    where:
    • host is the fully qualified host name of your gateway cluster.
    • org is the URL path of your organization.
    • catalog is the name of your Catalog.
    • api is the name of your API.
    • operation is the URL path of your operation.
  4. Take note of any parameters, the request body, and the response body. Code your application to create the expected requests and handle the expected responses.

Depending on the Identify your application using setting for the API, you might have to provide a client ID, or client ID and client secret. To do this, complete the following steps:

  1. To find the client ID, complete the following steps:
    1. Click Apps, then click the application name that you want to work with.
    2. Select the Show check box for Client ID.
      The client ID is displayed.
    3. Provide the client ID with the query parameter &client_id=
      For example, the URL used in the API might be:
      https://host/org/catalog/api/quote?loanAmount=20000
      but when you call it with a client ID of 1234, change the URL to:
      https://host/org/catalog/api/quote?loanAmount=20000&client_id=1234
  2. The client secret is produced when you register an application. Provide the client secret with the query parameter &client_secret=. If you did not note the client secret when you registered the application, you must reset it; for information, see Managing applications.

The client ID, or client ID and secret can be logged along with the URL. Web servers usually log the URL in their access logs, which would give away the client secret. If you do not want to expose your client ID or secret in the URL, complete the following steps.

  1. For the client ID, set the header, X-IBM-Client-Id, as part of the HTTP message that the application sends when it calls the API.
    An example URL statement might be:
    curl --header "X-IBM-Client-Id: 1234" https://host/org/catalog/api/quote?loanAmount=20000
  2. For the client secret, set the header, X-IBM-Client-Secret, as part of the HTTP message that the application sends when it calls the API.
    For example, the URL would be:
    https://host/org/catalog/api/quote?loanAmount=20000
    and set the following HTTP headers:
    X-IBM-Client-Id=1234
    X-IBM-Client-Secret=ABCD

What to do next

Monitor the API and application usage. For more information, see Managing applications.