Example: Application Management REST API

 Workflow: 
This example shows how to use the cloud operations Application Management REST API to manage the lifecycle of an enterprise application on a cloud subscription.

The example takes you through installing an enterprise application (.ear file) on a workflow server, updating it, starting and stopping it, and finally uninstalling it from the workflow server.
Before you begin
All API calls require a valid cross site forgery request (CSRF) token in the IBM®-CSRF-TOKEN header of the call. Obtain a CSRF token by using POST /instance/services/csrf_token. For more information, see Preventing cross site request forgery.
Manage the application lifecycle
  1. Display a list of the installed applications.
    Use the following call to retrieve a list of all the applications installed in an environment:
    GET /bpm/services/environments/{environment}/applications
    The environment parameter is mandatory; the values it can take depend on your subscription was configured. So, for the development environment, the call might be:
    GET /bpm/services/environments/dev/applications
    The API supports paging by using the offset and size parameter. For example,
    GET /bpm/services/environments/dev/applications?offset=3&size=10
  2. Install a new application.

    To install a new Integration Designer in the development environment, use the following call and include the application name and the .ear file as multipart/form-data in the call:

    POST /bpm/services/environments/dev/applications
    ...
    /**
     * Required header contains the key used as the boundary in the payload
    */
    Content-Type: multipart/form-data; boundary=---------------------------24104172026364
    ...
    /**
    	* The boundary specified in the header
    */
    -----------------------------24104172026364
    /**
    	* The application name, ACMoApp
    */
    
    Content-Disposition: form-data; name="application_name"
    AC_MOApp
    /**
    	* The .ear file as a binary stream
    */
    -----------------------------24104172026364
    Content-Disposition: form-data; name="ear"; filename="AC_MOPApp.ear"
    Content-Type: application/octet-stream
    application .ear file as binary stream
    -----------------------------24104172026364--
  3. Update an application.
    To update an enterprise application in the development environment, use the following call and include the updated .ear file as multipart/form-data in the call:
    POST /bpm/services/environments/dev/applications/AC_MOPApp
    ...
    /**
     * Required header contains the key used as the boundary in the payload
    */
    Content-Type: multipart/form-data; boundary=---------------------------24104172026364
    ...
    /**
    	* The boundary specified in the header
    */
    -----------------------------24104172026364
    Content-Disposition: form-data; name="ear"; filename="AC_MOPApp.ear"
    Content-Type: application/octet-stream
    application .ear file as binary stream
    -----------------------------24104172026364--
  4. Start an application.
    To start an enterprise application, for example, AC_MOPApp in the development environment, use the following call:
    POST /bpm/services/environments/dev/applications/AC_MOPApp/start
  5. Stop an application.
    To stop an enterprise application, for example, AC_MOPApp in the development environment, use the following call:
    POST /bpm/services/environments/dev/applications/AC_MOPApp/stop
  6. Delete an application.
    To delete an enterprise application, for example, AC_MOPApp in the development environment, use the following call:
    DELETE /bpm/services/environments/dev/applications/AC_MOPApp