Let’s assume we have a Spring Boot app with flowable-starter-rest and no security (for simpler curl requests) running on port 8989. This app has a single process named santaGiftRequest
:
It contains a service task to send your wish list to Santa and then a receive task named “getPresents”. You can use the following sequence to fully execute it via the REST API:
- Starting the process:
╭─williamwitt@Diagon-Alley.local ~
╰─➤ curl -X POST \
http://localhost:8989/process-api/runtime/process-instances \
-H 'Content-Type: application/json' \
-d '{
"processDefinitionKey": "santaGiftRequest"
}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 733 0 686 100 47 133k 9400 --:--:-- --:--:-- --:--:-- 143k
{
"id": "e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"url": "http://localhost:8989/process-api/runtime/process-instances/e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"name": null,
"businessKey": null,
"suspended": false,
"ended": false,
"processDefinitionId": "santaGiftRequest:1:573a866f-1d00-11ea-a2ac-1ee190cb6f7e",
"processDefinitionUrl": "http://localhost:8989/process-api/repository/process-definitions/santaGiftRequest:1:573a866f-1d00-11ea-a2ac-1ee190cb6f7e",
"processDefinitionName": "Santa Gift Request",
"processDefinitionDescription": null,
"activityId": null,
"startUserId": null,
"startTime": "2019-12-12T11:28:56.727-06:00",
"variables": [],
"callbackId": null,
"callbackType": null,
"tenantId": "",
"completed": false
}
- Find the execution
╭─williamwitt@Diagon-Alley.local ~
╰─➤ curl -X POST \
http://localhost:8989/process-api/query/executions/ \
-H 'Content-Type: application/json' \
-d '{
"processInstanceId": "e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"activityId": "getPresents"
}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 759 0 665 100 94 216k 31333 --:--:-- --:--:-- --:--:-- 247k
{
"data": [
{
"id": "e03b527e-1d04-11ea-a2ac-1ee190cb6f7e",
"url": "http://localhost:8989/process-api/runtime/executions/e03b527e-1d04-11ea-a2ac-1ee190cb6f7e",
"parentId": "e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"parentUrl": "http://localhost:8989/process-api/runtime/executions/e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"superExecutionId": null,
"superExecutionUrl": null,
"processInstanceId": "e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"processInstanceUrl": "http://localhost:8989/process-api/runtime/process-instances/e03b2b6c-1d04-11ea-a2ac-1ee190cb6f7e",
"suspended": false,
"activityId": "getPresents",
"tenantId": ""
}
],
"total": 1,
"start": 0,
"sort": "processInstanceId",
"order": "asc",
"size": 1
}
- Trigger the execution
╭─williamwitt@Diagon-Alley.local ~
╰─➤ curl -X PUT \
http://localhost:8989/process-api/runtime/executions/e03b527e-1d04-11ea-a2ac-1ee190cb6f7e \
-H 'Content-Type: application/json' \
-d '{
"action": "trigger",
"variables": [
{
"name": "myVariable",
"type": "string",
"value": "test"
}
]
}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 133 0 0 100 133 0 13300 --:--:-- --:--:-- --:--:-- 13300
Edit: If you’re using the prebuilt flowable-rest app, you’ll use basic authentication and the process endpoint is mapped at /flowable-rest/service/
instead of /process-api/
Will