Start of change

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.

Example

To discover details of the "default service version" for the service simpleSelect1 in the simpleTests collection ID, 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 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"
    }
}
End of change