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

Testing your API project PUT /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. Define the GET operation for the /phonebook/contacts/{lastName} path.
  5. Reusing the phonebook z/OS Asset.
  6. Mapping the API Request to the z/OS Asset.
  7. Defining the PUT /phonebook/contacts/{lastName} responses.

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 PUT /phonebook/contacts/{lastName} operation.

Procedure

  1. Open the PUT /phonebook/contacts/{lastName} Operation 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 in a new tab in your browser. The Open Liberty REST Client opens your OpenAPI definition automatically, 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 REST Client with your OpenAPI definition loaded.

    The editor 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 PUT /phonebook/contacts/{lastName} operation.
    1. Click anywhere on the PUT /contact operation bar to expand the PUT /contact operation.
    2. Click Try it out in the upper right of the operation section.
    3. Enter any name that exists in the phonebook in the lastName field.
      Smith
    4. In the request body field, input the details of the contact you want to update by using the following JSON request format:
      {
        "firstName": "Fred",
        "zipCode": "10504",
        "extension": "000-1234"
      }
      Test parameters in the Open Liberty REST Client.
    5. Click Execute.

      Figure 3 shows the result of a successful test. You can verify that the order was processed by using the /contacts operation, by viewing the response field stock and verifying that the count goes down by the quantity ordered. A failed test result is shown in Figure 4.

      Figure 3. A successful test result.
      A successful test result.
      Figure 4. A test result for a contact not in the phonebook
      A test result for a contact 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.