Testing the GET /phonebook/contacts/{lastName} operation

Testing your API project GET /phonebook/contacts/{lastName} operation with z/OS® Connect Designer by using the Open Liberty REST Client.

Before you begin

The following tasks must be completed:
  1. Prepare the sample IMS application.
  2. Starting the z/OS Connect Designer with Docker Desktop and importing an OpenAPI definition.
  3. Configuring connections to IMS with Docker Desktop and Basic Authentication.
  4. Creating the phonebook z/OS Asset.
  5. Mapping the API Request to the z/OS Asset.
  6. Defining the GET /phonebook/contacts/{lastName} responses.
  7. Mapping the API response fields.

About this task

This topic is applicable to: z/OS Connect Designer
capability Content applicable to
application developers

Learn how to test your newly configured GET /phonebook/contacts/{lastName} operation.

Procedure

  1. Open the API project flow diagram as described Mapping your API and z/OS Assets.
  2. In the upper right of the z/OS Connect Designer window, click Test.
    Figure 1. Location of the Test button.
    Location of the test button.

    The Open Liberty REST Client opens your OpenAPI definition in a new tab in your browser, ready to be tested.

    Table 1. Test API button status
    Indication Status
    Test API button enabled Enabled. Click the button to test your API.
    Test API button in unavailable state with loading indicator Button is unavailable with a loading indicator. The project build is running.
    Test API button in unavailable state with error indicator Button is unavailable with an error indicator. The project build failed. Hover over the button to see error information. For example, Test API button in unavailable state with error indicator and hover text with error message

    Figure 2. The Open Liberty REST Client available from the Liberty server with your OpenAPI definition loaded.
    The Open Liberty available from the Liberty server with your OpenAPI definition loaded.

    The Open Liberty REST Client lists the paths of your z/OS Connect API that are available to test. The Open Liberty REST Client acts as an HTTP client to test your OpenAPI by sending a RESTful request to your resources.

  3. Test the GET /phonebook/contacts/{lastName} operation.
    1. Click anywhere on the GET /phonebook/contacts/{lastName} operation bar to expand the GET /phonebook/contacts/{lastName} operation.
      Figure 3. Information about the GET /phonebook/contacts/{lastName} operation to be tested.
      Information about the GET /phonebook/contacts/{lastName} operation to be tested.

      In the expanded operation section, you see the parameters that you can select. For example, firstName.

    2. Click Try it out in the upper right of the operation section.
      Figure 4. The location of the Try it out button in the Open Liberty REST Client.
      The location of the Try it out button in the Open Liberty REST Client.
    3. Enter any name that exists in the phone book in the lastName field.
      Smith
    4. Click Execute.

      Figure 5 shows the result of a successful test. An unsuccessful test result is shown in Figure 6.

      Figure 5. A successful test result.
      A successful test result.
      Figure 6. A test result when the lastName is not in the phonebook
      A test result when the lastName is not in the phonebook

    You can also test your API in other REST Clients.

    Your API is hosted on your local workstation from a z/OS Connect server that is exposed as https://localhost:9443/phonebook/contacts/Smith.

    You can use this URL in any REST client of your choice and it returns successful responses. If a REST client is not available to you, use the Open Liberty REST Client within the Liberty server as demonstrated here. The Liberty server client is part of the ibm-zcon-designer image.

Results

You successfully tested your API.

What to do next

You can now continue to test with different mappings and explore the power of JSONata.