Discovering details of a Db2 REST service
You can use the Db2 REST service discover API to discover details of a service 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 discover details of the "default service version" for the service simpleSelect1
in the simpleTests
collection ID and 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 GET request:
GET https://<host>:<port>/services/simpleTests/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
Db2 returns the following response in JSON:
{
"simpleSelect1":{
"serviceURL":"<host>:<port>/services/simpleTests/simpleSelect1/V1",
"serviceStatus":"started",
"ResponseSchema":{
"$schema":"http://json-schema.org/draft-04/schema#",
"description":"Service simpleSelect1 invocation HTTP response body",
"properties":{
"StatusCode":{
"minimum":100,
"description":"Service invocation HTTP status code",
"maximum":600,
"multipleOf":1,
"type":"integer"
},
"ResultSet Output":{
"items":{
"description":"ResultSet Row",
"properties":{
"DEPTNAME":{
"maxLength":36,
"description":"VARCHAR(36)",
"type":"string"
}
},
"required":[
"DEPTNAME"
],
"type":"object"
},
"type":"array"
},
"StatusDescription":{
"description":"Service invocation status description",
"type":"string"
}
},
"required":[
"StatusDescription",
"StatusCode",
"ResultSet Output"
],
"type":"object"
},
"isDefaultVersion":true,
"RequestSchema":{
"$schema":"http://json-schema.org/draft-04/schema#",
"description":"Service simpleSelect1 invocation HTTP request body",
"properties":{
"LOCATION":{
"maxLength":16,
"description":"Nullable CHAR(16)",
"type":[
"null",
"string"
]
}
},
"required":[
"LOCATION"
],
"type":"object"
},
"alternateServiceURL":"<host>:<port>/services/simpleTests/simpleSelect1",
"serviceProvider":"db2service-1.0",
"serviceDescription":"Select deptname based on location.",
"version":"V1",
"serviceCollectionID":"simpleTests",
"serviceName":"simpleSelect1"
}
}