Hi,
I tried successfully to use the rest api with postman to restart a completed process, but in my cockpit plugin is not working and I cannot understand why I get error 400. for completeness I’m using the 7.14.5 and modified script from this tutorial: https://www.youtube.com/watch?v=BwsoozZRAqo
I started off with Nial example of WatchGame and from postman when I search the history with
“localhost:8080/engine-rest/history/process-instance” with the right body ’ { “processDefinitionKey”: “WatchGame”} ’ I get:
…
{ "id": "5560fdec-8054-11eb-bfdd-9cad97229f01", "businessKey": "myBusinessKey2", "processDefinitionId": "WatchGame:1:7438a1e9-801c-11eb-bfdd-9cad97229f01", "processDefinitionKey": "WatchGame", "processDefinitionName": "WatchGame", "processDefinitionVersion": 1, "startTime": "2021-03-08T22:22:06.296+0100", "endTime": "2021-03-09T07:04:33.173+0100", "removalTime": null, "durationInMillis": 31346877, "startUserId": null, "startActivityId": "StartEvent_1", "deleteReason": null, "rootProcessInstanceId": "5560fdec-8054-11eb-bfdd-9cad97229f01", "superProcessInstanceId": null, "superCaseInstanceId": null, "caseInstanceId": null, "tenantId": null, "state": "COMPLETED" },...
So I want to restart this process and I try in different ways with the same body:
- Postman Body:
{
“instructions”: [
{
“type”: “startBeforeActivity”,
“activityId”: “StartEvent_1”
}
],
“processInstanceIds”: [ “5560fdec-8054-11eb-bfdd-9cad97229f01” ],
“initialVariables”: true,
“skipCustomListeners”: true,
“withoutBusinessKey”: false
}
-
Postman call with extended api
http://localhost:8080/camunda/api/engine/engine/default/process-definition/WatchGame:1:7438a1e9-801c-11eb-bfdd-9cad97229f01/restart- not working error 401, and that is ok. I’m using and url from within the cockpit so it is understandable.
-
Postman with the short api call
localhost:8080/engine-rest/process-definition/WatchGame:1:7438a1e9-801c-11eb-bfdd-9cad97229f01/restart- this one works fine, code 204 and the instance is restarted.
-
From my plugin in the cockpit instead I have the following code and when run I get error 400:
fetch( api.engineApi + “/process-definition/” + “WatchGame:1:7438a1e9-801c-11eb-bfdd-9cad97229f01” +“/restart”, {
method: ‘post’,
body: {
“instructions”: [
{
“type”: “startBeforeActivity”,
“activityId”: “StartEvent_1”
}
],
“processInstanceIds”: [
“5560fdec-8054-11eb-bfdd-9cad97229f01”
],
“initialVariables” : true,
“skipCustomListeners” : true,
“withoutBusinessKey” : false
},
headers: {
“Accept”: “application/json”,
“Content-Type”: “application/json”,
“X-XSRF-TOKEN”: api.CSRFToken,
},
}).then(async (res) => {
var result = await res.json();
console.log(result);
});