Test the created Db2 native REST services to
ensure they are installed correctly.
About this task
Use a REST client to test the Db2 native REST services.
Three different API requests are made, one for each of the created Db2 native REST services.
For each request, replace <db2_host_name>
with the hostname of your Db2 instance and <db2_port>
with the port
of your Db2 instance. You can also include authentication
credentials such as the Authorization HTTP header.
Note: The examples in this tutorial use Versioning support. If you do not have versioning, then
remove the version from request URLs.
Procedure
- Use a REST client to test the
employeeList
service.
Send an HTTP POST request to
https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/employeeList/V1
with header
Content-Type: application/json
and the following body:
{}
A response code HTTP OK (200) indicates success. No JSON properties are
required for the employeeList
Db2 native REST service, so an empty JSON object payload is
used.
The response body starts with:
{
"ResultSet Output": [
{
"employeeNumber": "000150",
"firstName": "BRUCE",
"lastName": "ADAMSON",
"department": "D11"
},
...
],
"StatusCode": 200,
"StatusDescription": "Execution Successful"
}
- Use a REST client to test the
employeeDetails
service.
Send an HTTP POST request to
https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/employeeDetails/V1
with header
Content-Type: application/json
and the following body:
{
"employeeNumber": "000010"
}
A response code HTTP OK (200) indicates success. A JSON property named
employeeNumber
is required for the employeeDetails
Db2 native REST service. The value of this property is
inserted into the SQL statement that is executed.
The response body is:
{
"ResultSet Output": [
{
"employeeNumber": "000010",
"firstName": "CHRISTINE",
"lastName": "HAAS",
"department": "A00",
"phoneNumber": "3978",
"hireDate": "1965-01-01"
}
],
"StatusCode": 200,
"StatusDescription": "Execution Successful"
}
- Use a REST client to test the
employeeUpdate
service.
Send an HTTP POST request to
https://<db2_host_name>:<db2_port>/services/SYSIBMSERVICE/employeeUpdate/V1
with header
Content-Type: application/json
and the following body:
{
"employeeNumber": "000010",
"firstName": "CHRISTINE",
"lastName": "HAAS",
"department": "A00",
"phoneNumber": "3979",
"hireDate": "1965-01-01"
}
A response code HTTP OK (200) indicates success. Six JSON properties named
employeeNumber
, firstName
, lastName
,
department
, phoneNumber
, and hireDate
are
required for the employeeUpdate
Db2 native REST service. The values of both properties are
inserted into the SQL statement that is executed.
The response body is:
{
"Update Count": 1,
"StatusCode": 200,
"StatusDescription": "Execution Successful"
}
Results
The Db2 native REST services employeeList
,
employeeDetails
, and employeeUpdate
returned the expected responses.
What to do next
Complete the task Create a server to connect to Db2 to create a connection to the Db2 region in IBM z/OS Connect .