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

You must have one of the following privileges or authorities to discover details of a Db2 REST service:
  • Execute privilege on the package for the service
  • Ownership of the service
  • SYSADM or SYSCTRL authority
  • System DBADM.

Procedure

  • To discover service details, issue an HTTP or HTTPS GET request through a REST client with the following URI:
    GET https://<host>:<port>/services/<serviceCollectionID>/<serviceName>/<version>

    where

    • <serviceName> is the name of the new service that you specify.
    • <serviceCollectionID> is the identifier of the package that is associated with the new service.
    • <version> is the version identifier for REST service version to be discovered. The <version> portion of the URI is optional and is only valid to be used after REST service versioning has been enabled. If the <version> portion of the URI is not specified, then the default service version will be discovered.
  • Set the HTTP header Accept and Content-Type fields to application/json for the request.
  • Optional: Set any Db2 client information related HTTP header fields with values that will be assigned to the Db2 client information special registers. For more information, see Management of REST service client information.

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"
    }
}