Dropping a Db2 REST service

You can use the Db2 REST service manager API to drop a user-defined service if you have the required authority. Dropping a service removes the service, frees its associated package, and deletes the corresponding row from the SYSIBM.DSNSERVICE catalog table. You can also issue the FREE SERVICE subcommand to drop a REST service.

Before you begin

When you drop a service, you must have a privilege that allows the runner to free or drop the associated package. For required authorization, see FREE SERVICE (DSN).

Procedure

  • To drop a service, issue an HTTP or HTTPS POST request through a REST client with the following URI:
    POST https://<host>:<port>/services/DB2ServiceManager
  • 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.
  • Specify the following HTTP body for the request:
    {
     "requestType": "dropService",
     "collectionID": "<serviceCollectionID>",
     "serviceName": "<serviceName>",
     "version": "<version-id>"
    }
    

    where

    • dropService indicates that you request to remove a user-defined service.
    • <serviceCollectionID> is the identifier of the package that is associated with the service.
    • <serviceName> is the name of the service that you want to drop.
    • <version-id> is the version of the service you want to drop. If you omit the <version-id>, the default version of the REST service is deleted.

Example

This example shows how to drop the V1 version of service simpleSelect1, including 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/DB2ServiceManager

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:

{
 "requestType": "dropService",
 "collectionID": "SYSIBMSERVICE",
 "serviceName": "simpleSelect1",
 "version": "V1"
}

Db2 returns the following response in JSON:

{
 "StatusCode":200,
 "StatusDescription": "DB2 Rest Service SYSIBMSERVICE.simpleSelect1.(V1) was dropped successfully."
}

The response shows that service simpleSelect1 was successfully removed.