Authenticating flowable-task from other application

I have downloaded the flowable 6.4.2 source code and I’m going to use 3 modules in my application.

  1. flowable-ui-idm
  2. flowable-ui-modeler
  3. flowable-ui-task

I have created a small process, which involves a mail task.
I have a method which makes use of RuntimeService and it’s method startProcessInstanceByKey to start the process.

Problem comes when I try to call that method from another application,
I used below code to make a call and the method was GET as well.

ResponseEntity<String> triggerWorkFlow = mRestTemplate.getForEntity(
				"http://localhost:9999/flowable-task/app/rest/execution/start-process/"+processKey, 
				String.class);

Above call, doesn’t even reach the method which starts the process, however it does through java.net.ConnectException when flowable-task URL is not available.

Below is the value of triggerWorkFlow:

<200,<!doctype html>
<title>Flowable IDM</title>

<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png?v=Om5N75Y123">
<link rel="icon" type="image/png" href="images/favicon-32x32.png?v=Om5N75Y123" sizes="32x32">
<link rel="icon" type="image/png" href="images/favicon-16x16.png?v=Om5N75Y123" sizes="16x16">
<link rel="manifest" href="manifest.json">
<link rel="mask-icon" href="images/safari-pinned-tab.svg?v=Om5N75Y123" color="#506d75">
<link rel="shortcut icon" href="favicon.ico?v=Om5N75Y123">

<!-- build:css styles/common/3thparty.css -->
<link href="styles/common/bootstrap.min.css" rel="stylesheet">
<link href="libs/nvd3_1.1.15-beta/nvd3.min.css" rel="stylesheet">
<link href="libs/bootstrap-daterangepicker_1.3.7/daterangepicker-bs3.css" rel="stylesheet">
<!-- endbuild -->

<!-- build:css styles/style.css -->
<link href="styles/style-idm.css" rel="stylesheet">
<!-- endbuild -->

<!-- build:css styles/common/style.css -->
<link href="styles/common/style.css" rel="stylesheet">
<!-- endbuild -->
<div ng-if="!onLogin">

    <div class="navbar navbar-fixed-top navbar-inverse" role="navigation" id="main-nav" ng-show="authenticated">
        <div class="fixed-container">
            <div class="navbar-header">
                <a ng-click="backToLanding()" class="landing-logo" ng-if="account != null && account != undefined" title="{{'IDM.GENERAL.MAIN-TITLE' | translate}}">
                    <img ng-src="{{appResourceRoot}}images/flowable-logo.png" ng-srcset="{{appResourceRoot}}images/flowable-logo.png 1x, {{appResourceRoot}}images/flowable-logo@2x.png 2x">
                </a>
                <ul class="nav navbar-nav">
                    <li ng-repeat="item in mainNavigation"
                        id="{{item.id}}"
                        ng-show="(authenticated && !item.unauthenticated) || (item.unauthenticated && !authenticated)"
                        ng-class="{'active': item.id == mainPage.id}">
                        <a ng-click="setMainPage(item)">{{item.title | translate}}</a>
                    </li>
                </ul>
            </div>
            <div class="pull-right">
                <div class="dropdown btn-group btn-group-sm">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">{{account.firstName}} {{account.lastName}}
                        <span class="glyphicon glyphicon-chevron-down" style="font-size: 10px" aria-hidden="true"></span>
                    </button>
                    <ul class="dropdown-menu pull-right">
                        <li><a ng-click="logout()" translate="IDM.GENERAL.ACTION.LOGOUT"></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>


    <div class="wrapper clearfix" ng-view="" ng-cloak ng-style="{height: window.height + 'px'}">
    </div>

</div>

<div ng-if="onLogin">
    <div class="alert-wrapper" ng-cloak>
        <div class="alert {{alerts.current.type}}" ng-show="alerts.current" ng-click="dismissAlert()">
            <span>{{alerts.current.message}}</span>
            <span class="badge" ng-show="alerts.queue.length">{{alerts.queue.length + 1}}</span>
        </div>
    </div>
    <div ng-view="" ng-cloak ng-style="{height: window.height + 'px'}"></div>
</div>

<!--[if lt IE 9]>
<div class="unsupported-browser">
    <p class="alert error">You are using an unsupported browser. Please upgrade your browser in order to use the editor.</p>
</div>
<![endif]-->

<!--[if lt IE 9]>
<script src="libs/es5-shim-15.3.4.5/es5-shim.js"></script>
<script src="libs/json3_3.2.6/lib/json3.min.js"></script>
<![endif]-->

<!-- 3rd party libs -->
<script src="libs/jquery_1.11.0/jquery.min.js"></script>
<script src="libs/jquery-ui-1.10.3.custom.min.js"></script>

<script src="libs/angular_1.3.13/angular.js"></script>
<script src="libs/angular-animate_1.3.13/angular-animate.min.js"></script>
<script src="libs/bootstrap_3.1.1/js/bootstrap.min.js"></script>
<script src="libs/angular-resource_1.3.13/angular-resource.min.js"></script>
<script src="libs/angular-cookies_1.3.13/angular-cookies.min.js"></script>
<script src="libs/angular-sanitize_1.3.13/angular-sanitize.min.js"></script>
<script src="libs/angular-route_1.3.13/angular-route.min.js"></script>
<script src="libs/angular-translate_2.15.1/angular-translate.min.js"></script>
<script src="libs/angular-translate-storage-cookie/angular-translate-storage-cookie.js"></script>
<script src="libs/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
<script src="libs/angular-strap_2.1.6/angular-strap.min.js"></script>
<script src="libs/angular-strap_2.1.6/angular-strap.tpl.min.js"></script>
<script src="libs/ng-file-upload/ng-file-upload-shim.min.js"></script>
<script src="libs/ng-file-upload/ng-file-upload.min.js"></script>
<script src="libs/ui-grid_3.0.0/ui-grid.min.js" type="text/javascript"></script>
<script src="libs/autofill-events_1.0.0/autofill-event.js"></script>
<script src="libs/momentjs_2.18.1/momentjs.min.js"></script>

<!-- Configuration -->
<script src="scripts/app-cfg.js?v=2"></script>

<!-- build:js scripts/scripts.js -->
<script src="scripts/idm-app.js"></script>
<script src="scripts/idm-service.js"></script>
<script src="scripts/idm-user-mgmt-controller.js"></script>
<script src="scripts/idm-group-mgmt-controller.js"></script>
<script src="scripts/idm-profile-mgmt-controller.js"></script>
<script src="scripts/idm-privilege-mgmt-controller.js"></script>
<script src="scripts/common/services/authentication-service.js"></script>
<script src="scripts/common/directives.js"></script>
<script src="scripts/common/providers-config.js"></script>
<script src="scripts/common/services/user-service.js"></script>
<script src="scripts/common/services/group-service.js"></script>
<script src="scripts/controllers.js"></script>

<!-- endbuild -->

<!-- Integration extensions -->
<script src="scripts/resource-loader.js?v=2" app="landing"></script>

Method which is used to start Process is:

@RequestMapping(value = "/start-process/{processKey}", method = RequestMethod.GET)
    public void startProcess(@PathVariable("processKey") String processKey) {
    	System.out.println("STARTING PROCESS");
    	mRuntimeService.startProcessInstanceByKey(processKey);
    }

I believe there is an issue with authentication but it doesn’t throw any exception anywhere.
So, how do I make this REST TEMPLATE CALL
Let me know if any details are required from my end.

The REST endpoint you’re looking for is http://localhost:9999/flowable-task/process-api/runtime/process-instances . You’ll POST a JSON object containing a processDefinitionKey to start the process using basic auth.

There is Swagger documentation available for the Flowable REST api as part of the flowable-rest WAR at /docs/. It’s the same API that’s available to you in flowable-task, but the paths are slightly different.

Will

1 Like

Thanks Will !!
The REST endpoint which you provided : http://localhost:9999/flowable-task/process-api/runtime/process-instances worked fine.

And Yes, there is a similar API in flowable-task, used to start new Process Instance http://localhost:9999/flowable-task/app/rest/process-instances , which takes JSON object having value of processDefinitionId , which is again obtained from API http://localhost:9999/flowable-task/app/rest/process-definitions?latest=true , whose response is,

{
  "size": 1,
  "total": 1,
  "start": 0,
  "data": [
    {
      "id": "processdemo:2:b7e88899-c4c2-11e9-93d6-525349d6ad33",//processDefinitionId
      "name": "ProcessDemo",
      "description": null,
      "key": "processdemo",
      "category": "http://www.flowable.org/processdef",
      "version": 2,
      "deploymentId": "b7cb8ab6-c4c2-11e9-93d6-525349d6ad33",
      "tenantId": "",
      "hasStartForm": false
    }
  ]
}

When using above processDefinitionId as request body for API, http://localhost:9999/flowable-task/app/rest/process-instances , I am able to start the process from Swagger of flowable-ui-task, but if I try to start the process from POSTMAN, it behaves in the same way I described in my question. (process doesn’t get started and nothing happens in flowable-ui-task console in IDE)

I’m gonna use the endpoint which you provided, but I’m not sure why it doesn’t work

  • What does Postman show when dong the call? It should show at least the status code
  • Are you sure you’re running all of the apps against the same database?

Hi Joram,

I started using floowable as a dependency now and don’t remember now what was the status code and yes all flowable apps were using same database, which I changed in flowable-default.properties

In that case I’m a bit puzzled … typically that’s the problem. Can you maybe check your database (e.g. the ACT_RU_EXECUTION) table to see if data gets actually added?