Start of change

Calling a provided REST API

You can call certain features in Db2 Admin Tool as REST APIs by using one of the provided stored procedures. For example, you can get space estimates for index spaces by using the ADB2MEX stored procedure.

About this task

For a list of available REST APIs and the corresponding stored procedure name, see Provided REST APIs.

Procedure

To call a Db2 Admin Tool function as a REST API:

  1. Set up the provided REST APIs.
  2. Call one of the provided REST APIs by using an API development tool.

    The process varies based on the tool. Generally, you need to create a new request, specify the URL for your REST service, select the POST method, and provide your input data in JSON format. For example, you can provide the following input data for ADB2MEX:

    { "ROWS": 3334455,
    "KEYLEN": 2000,
    "UNIQUE": "y",
    "DISTINCT": null,
    "ROWSPKEY": null,
    "CMPRATIO": null,
    "PAGESIZE": null,
    "PCTFREE": null,
    "FREEPAGE": null,
    "LARGETS": "Y",
    "UNITTYPE": null,
    "EAV": null,
    "PIECENUM": null,
    "PIECESIZE": ""
    }

    Also, by default, sufficient authorization is required for the stored procedure. You must pass valid LPAR credentials (login ID and password) to call the procedure.

    After you send the request, the relevant stored procedure sends a response. For example, the following response is for ADB2MEX:

    
    {
        "Output Parameters": 
    {      "RES": "\
    {\"rc\":0,\"pgusea\":3836,\"pgrows\":1,\"pgleaf\":3334455,\"ixlevels\":22,\"pgtot\":6669743,\"estkb\":26678972,\"pqty\":26679600,\"pqtyexpl\":\"
    (37055 cyls)\",\"sqty\":2668320,\"sqtyexpl\":\"
    (3706 cyls)\",\"sugpiece\":\"2097152 K\",\"esttrks\":555812,\"estcyls\":37055,\"snum\":12,\"msg\":\"Successful completion\"}
    "
        },
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }

    In the case of ADB2MEX, if an error occurs (for example, some required parameters are missing), the response from the procedure contains the return code and an error message. For example:

    {
        "Output Parameters": 
    {      "RES": "\{\"rc\":-1,\"emsg\":\"One or more of the required parameters are missing\"}
    "
        },
        "StatusCode": 200,
        "StatusDescription": "Execution Successful"
    }
End of change