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
- Use a REST client to test the
getEmployeesservice.Send an HTTP POST request tohttps://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/getEmployees/V1with headerContent-Type: application/jsonand the following body:
A response code HTTP OK (200) indicates success. The response body is structured like this:{ "WORKDEPT": "%", "JOB": "%" }{ "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" } - Use a REST client to test the
getEmployeeservice.Send an HTTP POST request tohttps://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/getEmployee/V1with headerContent-Type: application/jsonand the following body:
A response code HTTP OK (200) indicates success. A JSON property that is called{ "EMPNO": "000150" }EMPNOis required for thegetEmployeeDb2 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" } - Optional: Use a REST client to test the
addEmployeeservice.Send an HTTP POST request tohttps://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/addEmployee/V1with a header ofContent-Type: application/jsonand the following body:
A response code HTTP Created (201) indicates that the employee was created. The{ "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 }getEmployeeDb2 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" } - Optional: Use a REST client to test the
updateEmployeeservice.Send an HTTP POST request tohttps://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/updateEmployee/V1with a header ofContent-Type: application/jsonand the following body:
A response code HTTP OK (200) indicates that the employee was updated. The{ "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 }getEmployeeDb2 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" } - Optional: Use a REST client to test the
deleteEmployeeservice.Send an HTTP POST request tohttps://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/deleteEmployee/V1with a header ofContent-Type: application/jsonand the following body:
A response code HTTP OK (200) indicates that the employee was deleted. The{ "EMPNO": "123456" }getEmployeeDb2 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.