cancel
Showing results for 
Search instead for 
Did you mean: 

Process Instance started over REST are not showing

twiinart
Champ in-the-making
Champ in-the-making
I am trying to start a process instance over REST API with the below POST which seems to be working well:

POST http://localhost:8080/activiti-rest/service/runtime/process-instances
With the following json contant in the body:

{
    "processDefinitionId":"SimpleVariableProcess2:1:210004",
    "variables": [
      {
        "name":"id",
        "value":"test_id"
      },
      {
        "name":"href",
        "value":"test_href"
      },
      {
        "name":"name",         
        "value":"test_name"
      }
   ]
}

If I am posting this everything seem to be fine. I get an 201 Created and the following JSON answer:
{
  "id": "215305",
  "url": "http://localhost:8080/activiti-rest/service/runtime/process-instances/215305",
  "businessKey": null,
  "suspended": false,
  "ended": true,
  "processDefinitionId": "SimpleVariableProcess2:1:210004",
  "processDefinitionUrl": "http://localhost:8080/activiti-rest/service/repository/process-definitions/SimpleVariableProcess2:1:...",
  "activityId": "endevent1",
  "variables": [],
  "tenantId": "",
  "completed": true
}

But If I am searching with a GET in all the process instances it does not show up there e.g:
GET http://localhost:8080/activiti-rest/service/runtime/process-instances/215305

With that I get 404 Not found and the JSON answer:
{
  "message": "Not found",
  "exception": "Could not find a process instance with id '215305'."
}

What am I doing wrong?

Thank you for your help
Martin
7 REPLIES 7

hari
Star Contributor
Star Contributor
May be it has started but not persisted to db yet. I came across this kind of thing earlier.

twiinart
Champ in-the-making
Champ in-the-making
And how would I ensure that it has been persisted in the db?

jbarrez
Star Contributor
Star Contributor
That sounds very odd … do you have an example process that we can try with those REST calls? When you get back a 201, it should be persisted.

twiinart
Champ in-the-making
Champ in-the-making
thank you for your answer. It happens with every process. For example with the process below (just a start and stop event):
<blockcode>
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="280.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="470.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="315.0" y="297.0"></omgdi:waypoint>
        <omgdi:waypoint x="470.0" y="297.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</blockcode>

twiinart
Champ in-the-making
Champ in-the-making
Even more strange is that, if I look into the database (table ACT_HI_PROCINST) the process instance seems to be there (ID_ 17629):

<code>
ID_ PROC_INST_ID_ BUSINESS_KEY_ PROC_DEF_ID_ START_TIME_ END_TIME_ DURATION_ START_USER_ID_ START_ACT_ID_ END_ACT_ID_ SUPER_PROCESS_INSTANCE_ID_ DELETE_REASON_ TENANT_ID_ NAME_
17538 17538 NULL SimpleVariableProcess:1:12504 2016-06-21 09:15:08.977 2016-06-21 09:15:14.707 5732 kermit startevent1 endevent1 NULL NULL  NULL
17575 17575 NULL procCallPowerShell:1:20004 2016-06-21 09:15:09.060 2016-06-21 09:15:11.973 2915 kermit startevent1 endevent1 17538 NULL  NULL
17600 17600 NULL procCallPowerShell:1:20004 2016-06-21 09:15:12.080 2016-06-21 09:15:14.627 2544 kermit startevent1 endevent1 17538 NULL  NULL
17629 17629 NULL myProcess:1:25008 2016-06-21 10:12:07.053 2016-06-21 10:12:07.070 17 kermit startevent1 endevent1 NULL NULL  NULL
</code>

But If I call the REST API for the this process instance with GET "http://localhost:8080/activiti-rest/service/runtime/process-instances/17629" I get back:
<code>
{
  "message": "Not found",
  "exception": "Could not find a process instance with id '17629'."
}
</code>

and if I just call the REST API for all process instances with GET "http://localhost:8080/activiti-rest/service/runtime/process-instances/" I get back:
<code>
{
  "data": [],
  "total": 0,
  "start": 0,
  "sort": "id",
  "order": "asc",
  "size": 0
}
</code>

As I have shown above there are several process instance which should be returned, but are not 😞

jbarrez
Star Contributor
Star Contributor
a start->end process immediately is finished. If you want to be able to query like you do, your process needs to have a wait state (like a user task).

twiinart
Champ in-the-making
Champ in-the-making
OK, thank you for the clarification