Contact Us 1-800-596-4880

Managing Applications Using REST APIs

The management console provides REST APIs that you can use to programmatically access much of the console’s functionality. Among the operations that you can request with the REST APIs are operations related to managing applications in a repository. This includes finding, uploading, and deleting applications inside the repository.

See Using the Management Console APIs for an overview of the REST APIs, including a basic example of use, and a summary of returned status codes and error handling codes.

This page provides a brief description of each REST API for application management, an HTTP method to invoke the API, and a usage example. The examples show how to invoke the API using cURL, the command line HTTP tool.

Note: The notation \{mmc base} refers to the console base address. The console base address used in the examples is http://localhost:8080/mmc and configured with the default username and password (admin:admin).

The table below summarizes the REST APIs for application management:

Task Resource Description HTTP Invocation Method

Get Information About Applications

\{mmc base}/api/repository

Returns information about applications in the repository

GET

Upload an Application

\{mmc base}/api/repository

Uploads an application to the repository

POST

Delete an Application

\{mmc base}/api/repository/<applicationId>

Deletes the specific application from the repository

DELETE

Get Information About Applications

Returns information about applications in the repository.

HTTP Method:

GET

URL:

http://{mmc base}/api/repository

Parameters:

path: An optional parameter that specifies a path in which to look for applications in the repository. The default path is /Applications/.

Example: Get information about applications

Request:

curl --basic -u admin:admin http://localhost:8080/mmc/api/repository

JSON Response:

{
    "data": [
        {
            "href": "http://localhost:8080/mmc/api/repository/local$c70fe77e-293c-4fd0-a47b-9da85501171a",
            "id": "local$c70fe77e-293c-4fd0-a47b-9da85501171a",
            "name": "test-app",
            "versions": [
                {
                    "id": "local$09440704-2654-4301-bd35-a0b2ae706313",
                    "name": "1.0",
                    "parentPath": "/Applications/test-app"
                }
            ]
        }
    ],
    "total": 1
}

Example: Get information about a specific application

Request:

curl --basic -u admin:admin http://localhost:8080/mmc/api/repository/'local$c70fe77e-293c-4fd0-a47b-9da85501171a'

JSON Response:

{
    "data": [
        {
            "id": "local$09440704-2654-4301-bd35-a0b2ae706313",
            "name": "1.0",
            "parentPath": "/Applications/test-app"
        }
    ],
    "total": 1
}

Upload an Application

Uploads an application to the repository.

HTTP Method:

POST

URL:

http://{mmc base}/api/repository

Parameters:

The following parameters are specified as form parameters in the cURL command:

file: The file stream to be uploaded.
name: The name of the application to be uploaded.
version. A string that specifies the version ID of the application (by default, the date and time).

Example:

Request:

curl --basic -u admin:admin -F file=@my-zipped-app.zip -F name=test-app -F version=2.0 --header 'Content-Type: multipart/form-data' http://localhost:8080/mmc/api/repository

Note: make sure you have your zipped app in your current folder otherwise curl will fail creating the formpost data.

Response:

{
    "applicationId": "local$c70fe77e-293c-4fd0-a47b-9da85501171a",
    "versionId": "local$75e22cd7-ce94-422a-9987-aa0403713e3e"
}

To view information about the uploaded application execute the following command:

curl --basic -u admin:admin http://localhost:8080/mmc/api/repository/'local$c70fe77e-293c-4fd0-a47b-9da85501171a'
{
    "data": [
        {
            "id": "local$09440704-2654-4301-bd35-a0b2ae706313",
            "name": "1.0",
            "parentPath": "/Applications/test-app"
        },
        {
            "id": "local$75e22cd7-ce94-422a-9987-aa0403713e3e",
            "name": "2.0",
            "parentPath": "/Applications/test-app"
        }
    ],
    "total": 2
}

Remove an Application

Deletes an application from the repository.

HTTP Method:

POST

DELETE:

http://{mmc base}/api/repository/<applicationId>

Parameters:

applicationId: The ID of the application to be deleted.

Example:

Request:

curl --basic -u admin:admin -X DELETE http://localhost:8080/mmc/api/repository/'local$09440704-2654-4301-bd35-a0b2ae706313'

To view information about the deleted application, execute the following command:

curl --basic -u admin:admin http://localhost:8080/mmc/api/repository/'local$c70fe77e-293c-4fd0-a47b-9da85501171a'
{
    "data": [
        {
            "id": "local$75e22cd7-ce94-422a-9987-aa0403713e3e",
            "name": "2.0",
            "parentPath": "/Applications/test-app"
        }
    ],
    "total": 1
}