Testing the sample Db2 native REST services

How to test the created Db2 native REST services to help ensure that they are installed correctly.

About this task

zosConnect-3.0 Applies to zosConnect-3.0.

Containers Applies to z/OS Connect container deployments.

Use a REST client to test the Db2 native REST services. Two different API requests are made, one for each of the Db2 native REST services.

For each request, replace <db2_host_name> with the hostname and <db2_port> with the port of your Db2 instance. You can also include authentication credentials such as the Authorization HTTP header.

Procedure

  1. Use a REST client to test the getEmployees service.
    Send an HTTP POST request to https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/getEmployees/V1 with header Content-Type: application/json and the following body:
    {
        "WORKDEPT": "%",
        "JOB": "%"
    }
    A response code HTTP OK (200) indicates success. The response body is structured like this:
    {
        "ResultSet Output": [
            {
                "EMPNO": "000150",
                "FIRSTNME": "BRUCE",
                "MIDINIT": " ",
                "LASTNAME": "ADAMSON",
                "WORKDEPT": "D11",
                "PHONENO": "2222",
                "HIREDATE": "1972-02-12",
                "JOB": "DESIGNER",
                "EDLEVEL": 16,
                "SEX": "M",
                "BIRTHDATE": "1947-05-17",
                "SALARY": 25280.00,
                "BONUS": 500.00,
                "COMM": 2022.00
            },
            ...
        ],
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }
  2. Use a REST client to test the getEmployee service.
    Send an HTTP POST request to https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/getEmployee/V1 with header Content-Type: application/json and the following body:
    {
        "EMPNO": "000150"
    }
    A response code HTTP OK (200) indicates success. A JSON property that is called EMPNO is required for the getEmployee Db2 native REST service. The value of this property is inserted into the SQL statement that is run. The response body is:
    {
        "ResultSet Output": [
            {
                "EMPNO": "000150",
                "FIRSTNME": "BRUCE",
                "MIDINIT": " ",
                "LASTNAME": "ADAMSON",
                "WORKDEPT": "D11",
                "PHONENO": "2222",
                "HIREDATE": "1972-02-12",
                "JOB": "DESIGNER",
                "EDLEVEL": 16,
                "SEX": "M",
                "BIRTHDATE": "1947-05-17",
                "SALARY": 25280.00,
                "BONUS": 500.00,
                "COMM": 2022.00
            }
        ],
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }
  3. Optional: Use a REST client to test the addEmployee service.
    Send an HTTP POST request to https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/addEmployee/V1 with a header of Content-Type: application/json and the following body:
    {
        "EMPNO": "123456",
        "FIRSTNME": "TEST",
        "MIDINIT": "A",
        "LASTNAME": "EMPLOYEE",
        "WORKDEPT": "A00",
        "PHONENO": "1234",
        "HIREDATE": "2000-01-01",
        "JOB": "MANAGER",
        "EDLEVEL": 12,
        "SEX": "M",
        "BIRTHDATE": "1999-01-01",
        "SALARY": 12345.00,
        "BONUS": 123.00,
        "COMM": 456.00
    }
    A response code HTTP Created (201) indicates that the employee was created. The getEmployee Db2 native REST service can be used to verify this. The values within the provided body are inserted into the SQL statement that is run. The response body is:
    {
        "Update Count": 1,
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }
  4. Optional: Use a REST client to test the updateEmployee service.
    Send an HTTP POST request to https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/updateEmployee/V1 with a header of Content-Type: application/json and the following body:
    {
        "EMPNO": "123456",
        "FIRSTNME": "UPDATE_TEST",
        "MIDINIT": "A",
        "LASTNAME": "EMPLOYEE",
        "WORKDEPT": "A00",
        "PHONENO": "1234",
        "HIREDATE": "2000-01-01",
        "JOB": "MANAGER",
        "EDLEVEL": 12,
        "SEX": "M",
        "BIRTHDATE": "1999-01-01",
        "SALARY": 12345.00,
        "BONUS": 123.00,
        "COMM": 456.00
    }
    A response code HTTP OK (200) indicates that the employee was updated. The getEmployee Db2 native REST service can be used to verify this. The values within the provided body are inserted into the SQL statement that is run. The response body is:
    {
        "Update Count": 1,
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }
  5. Optional: Use a REST client to test the deleteEmployee service.
    Send an HTTP POST request to https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/deleteEmployee/V1 with a header of Content-Type: application/json and the following body:
    {
        "EMPNO": "123456"
    }
    A response code HTTP OK (200) indicates that the employee was deleted. The getEmployee Db2 native REST service can be used to verify this. The values within the provided body are inserted into the SQL statement that is run. The response body is:
    {
        "Update Count": 1,
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }

Results

The Db2 native REST services getEmployee, and getEmployees returned the expected responses.