Testing an API with the policies editor

IBM® API Connect provides a basic test environment in the Policies editor so that you can ensure that your APIs are defined and implemented correctly.

About this task

You can complete this task either by using the API Designer UI application, or by using the browser-based API Manager UI.

Note:
  • If you are testing an OpenAPI 2.0 API, you can use either the Policies editor test tool that is described here, or you can use the Test tab. If you are testing an OpenAPI 3.0 API, only the Test tab is available; see Using the Test tab to debug your API.
  • If you are testing an API that contains references to API properties, only those references that are defined inside the API assembly are resolved and replaced with their corresponding values when you call the API in the assembly test tool. The property references that are defined outside of the API assembly are not resolved during the test. For more information on API properties, see Setting API properties (OpenAPI 2.0) or Setting API properties (OpenAPI 3.0).
  • Due to Cross-Origin Resource Sharing (CORS) restrictions, the assembly test tool cannot be used with the Chrome or Safari browsers on the macOS Catalina platform.

Procedure

To test an API, complete the following steps.

  1. If you are using API Designer, set the mode to Online using the Options menu Options menu on the main page.
  2. In the navigation pane, click Develop icon in the API UI navigation pane Develop, then select the APIs tab.
  3. Click the title of the API that you want to work with.
  4. Click the Gateway tab then, in the navigation pane, click Policies.
  5. If you are testing the API for the first time and, when you created the API definition, you selected the Activate API option, your test setup will already be configured and you can proceed immediately to the next step to test your API. Otherwise, click Offline to toggle the API to the Online state. If you are retesting your API after modifying the API, the modified APIs are republished automatically on saving.
  6. Click the Test icon Test icon (right arrow).
    Note:
    • The Test icon is active only if you have toggled your API to the Online state, as described in step 5.
    • The Catalog, Product, Plan, and application details that are displayed in the Setup pane reflect your configured API testing preferences; see Specifying the testing preferences for an API,
  7. In the Operation section, select the API operation that you want to test, then click Invoke.
    The API response is displayed in the Response section.
    Note: If you receive a message that is associated to an untrusted certificate, perform the following steps:
    1. Click the link that is provided.
    2. Accept the certificate.
    3. Return to the test environment.
    4. Click Invoke again.
    The message also mentions a lack of CORS support on the server that is one of the possible causes for the connection failure.