Invoking a Db2 REST service
You can invoke a Db2 REST service through a RESTful HTTP client if you have the required authority.
Before you begin
- Execute privilege on the package for the service
- Ownership of the service
- SYSADM or SYSCTRL authority
- System DBADM.
Procedure
Example
This example shows how to invoke the default version of the service SYSIBMSERVICE.simpleSelect1
, which has a single input String parameter named LOCATION. This example includes setting the Db2-Client-ApplName and Db2-Client-WrkStnName HTTP request header fields to the values "Customer Service" and "CS Laptop-47", respectively. Enter the following URI to start an HTTPS POST request:
POST https://<host>:<port>/services/SYSIBMSERVICE/simpleSelect1
Specify the following HTTP header fields for the request:
Accept:application/json
Content-Type:application/json
Db2-Client-ApplName:Customer Service
Db2-Client-WrkStnName:CS Laptop-47
Specify the following HTTP body for the request:
{
"LOCATION": "<location>"
}
Db2 returns the following response in JSON:
{
"ResultSet Output":
{
"DEPTNAME": "SPIFFY COMPUTER SERVICE DIV."
},
{
"DEPTNAME": "PLANNING"
},
{
"DEPTNAME": "INFORMATION CENTER"
},
{
"DEPTNAME": "DEVELOPMENT CENTER"
},
{
"DEPTNAME": "MANUFACTURING SYSTEMS"
},
{
"DEPTNAME": "ADMINISTRATION SYSTEMS"
},
{
"DEPTNAME": "SUPPORT SERVICES"
},
{
"DEPTNAME": "OPERATIONS"
},
{
"DEPTNAME": "SOFTWARE SUPPORT"
},
{
"DEPTNAME": "BRANCH OFFICE F2"
},
{
"DEPTNAME": "BRANCH OFFICE G2"
},
{
"DEPTNAME": "BRANCH OFFICE H2"
},
{
"DEPTNAME": "BRANCH OFFICE I2"
},
{
"DEPTNAME": "BRANCH OFFICE J2"
},
"StatusCode": 200,
"StatusDescription": "Execution Successful."
}
The response shows that service simpleSelect1
was successfully invoked.