Creating a Db2 REST service
You can use the Db2 REST service manager API, or createService API, to create a new user-defined service if you have the required authority. You can also issue the BIND SERVICE subcommand to create a new REST service.
Before you begin
Before you can
create a service, you must apply APARs and create database objects that are required by the
services. For instructions, see Enabling Db2 REST services.
Data Studio provides no support for creating or
deploying Db2 REST services.
Procedure
Example
To create service simpleSelect1 for OWNER DB2GRP1 and
QUALIFIER USRT002, enter the following URI to start an HTTPS POST
request:
POST https://host:port/services/DB2ServiceManagerSpecify the following HTTP header fields for the request:
Accept:application/json
Content-Type:application/jsonSpecify the following HTTP body for the request:
{
"requestType": "createService",
"sqlStmt": "SELECT DEPTNAME FROM DSN8B10.DEPT WHERE LOCATION = :LOCATION",
"collectionID": "SYSIBMSERVICE",
"serviceName": "simpleSelect1",
"description": "Select department name based on location.",
"owner": "DB2GRP1",
"qualifier": "USRT002"
}
Db2 returns the following response in JSON:
{
"StatusCode":201,
"StatusDescription":"DB2 Rest Service simpleSelect1 was created successfully.",
"URL": "http://<host>:<port>/services/SYSIBMSERVICE/simpleSelect1/V1"
"StatusOptions": {
"Applied":[
{
"ACTION": "ADD"
},
{
"VALIDATE": "RUN"
},
{
"EXPLAIN": "NO"
},
{
"ISOLATION": "CS"
},
{
"RELEASE": "COMMIT"
},
{
"OWNER": "DB2GRP1"
},
{
"QUALIFIER": "USRT002"
},
{
"APREUSE": ""
},
{
"APCOMPARE": ""
},
{
"BUSTIMESENSITIVE": "YES"
},
{
"SYSTIMESENSITIVE": "YES"
},
{
"ARCHIVESENSITIVE": "YES"
},
{
"APPLCOMPAT": "V12R1M500"
},
{
"DESCSTAT": "YES"
},
{
"SQLERROR": "NOPACKAGE"
},
{
"CURRENTDATA": "NO"
},
{
"DEGREE": "1"
},
{
"NODEFER": "PREPARE"
},
{
"REOPT": "NONE"
},
{
"IMMEDWRITE": "NO"
},
{
"DBPROTOCOL": "DRDA"
},
{
"OPTHINT": ""
},
{
"ENCODING": "UNICODE(01208)"
},
{
"CONCURRENTACCESSRESOLUTION": ""
},
{
"PATH": ""
},
{
"QUERYACCELERATION": ""
},
{
"GETACCELARCHIVE": ""
},
{
"ACCELERATOR": ""
},
}
The
response shows that service simpleSelect1 was successfully created. Since version
was not specified, the version of the service created defaults to V1.If
necessary, you can issue the REBIND PACKAGE command to modify the options
associated with service simpleSelect1 .
