cancel
Showing results for 
Search instead for 
Did you mean: 

REST API creates the tasks with assignee defaulted as login user

shailk
Champ in-the-making
Champ in-the-making
I am creating BPMN process instance in which first step creates user task which is external (orbeon) form capture.

I am calling runtime/process-instances REST API which has initiator variable parameter passed as "kermit" but nothing is defined in BPMN process XML but even though the assignee is always updated as "kermit" and owner is also updated as "kermit".

I am attaching herewith BPMN process xml and the output from rest client.


id: "22510"
url: "http://localhost:8082/activiti-rest/service/runtime/tasks/22510"
owner: "kermit"
assignee: "kermit"
delegationState: null
name: "Capture form"
description: null
createTime: "2015-06-15T16:32:55.417+01:00"
dueDate: "2015-06-15T17:02:55.420+01:00"
priority: 50
suspended: false
taskDefinitionKey: "theTask"
tenantId: ""
category: null
formKey: "http://localhost:8082/orbeon/fr/TestWorkflow/TestWorkflow/new"
parentTaskId: null
parentTaskUrl: null
executionId: "22501"
executionUrl: "http://localhost:8082/activiti-rest/service/runtime/executions/22501"
processInstanceId: "22501"
processInstanceUrl: "http://localhost:8082/activiti-rest/service/runtime/process-instances/22501"
processDefinitionId: "oneTaskProcess:1:34"
processDefinitionUrl: "http://localhost:8082/activiti-rest/service/repository/process-definitions/oneTaskProcess:1:34"
variables: [0]


17 REPLIES 17

jbarrez
Star Contributor
Star Contributor
Ok, so I tried to reproduce:

1. Posted the oneTaskProcess.bpmn20.xml you have in the post above: POST to localhost:8080/activiti-rest/service/repository/deployments
2. Start the process instance : POST to localhost:8080/activiti-rest/service/runtime/process-instances with in the body the process definition key
3. Get all tasks in the system: GET localhost:8080/activiti-rest/service/runtime/tasks

which returns

<code>
{"data":[{"id":"47","url":"http://localhost:8080/activiti-rest/service/runtime/tasks/47','owner':null,'assignee':null,'delegati... form","description":null,"createTime":"2015-06-30T22:52:07.955+02:00","dueDate":"2015-06-30T23:22:07.980+02:00","priority":50,"suspended":false,"taskDefinitionKey":"theTask","tenantId":"","category":null,"formKey":"http://localhost:8082/orbeon/fr/TestWorkflow/TestWorkflow/new','parentTaskId':null,'parentTaskUrl':n...":[]}],"total":1,"start":0,"sort":"id","order":"asc","size":1}
</code>

so no assignee

Also GET localhost:8080/activiti-rest/service/runtime/tasks?assignee=kermit

returns

<code>
{"data":[],"total":0,"start":0,"sort":"id","order":"asc","size":0}
</code>

So what is different from what you are doing?

shailk
Champ in-the-making
Champ in-the-making
I am not sure what version of activiti software you are using.
I have recently downloaded activiti-5.17.0.zip file from the website hence I am using that version.

What authentication information are you posting for creating process instance?

trademak
Star Contributor
Star Contributor
This is not specific to a version of Activiti, because we didn't change anything in that area.
I see you have defined kermit as the owner of the handleRequest task, why is that? Did you try to remove the owner expression?

Best regards, 

shailk
Champ in-the-making
Champ in-the-making
Yes but that's the second task in process whereas when create process instance starts the first task is created and assigned to kermit by default. This is the user used when authenticated to Activiti using REST API.

I am not trying something different here  but its simple REST API call with basic authentication details.

I am not sure how jbarrez was unable to produce the same using the latest activiti software published on the website.

vasile_dirla
Star Contributor
Star Contributor
Created test to check the assignee value of the first task on the process you submitted here.
The assignee value is null.

<code>
public class TaskAssignmentTest extends BaseSpringRestTestCase {
public void testOneTaskProcessInstance() throws Exception {
    try {
      // Upload a valid BPMN-file using multipart-data
      HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_COLLECTION));
      httpPost.setEntity(HttpMultipartHelper.getMultiPartEntity("ProcessInstanceResourceTest.oneTaskProcess.bpmn20.xml", "application/xml",
              ReflectUtil.getResourceAsStream("org/activiti/rest/service/api/runtime/ProcessInstanceResourceTest.oneTaskProcess.bpmn20.xml"), null));
      CloseableHttpResponse response = executeBinaryRequest(httpPost, HttpStatus.SC_CREATED);

      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);


      httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION));
      ProcessInstanceCreateRequest data = new ProcessInstanceCreateRequest();
      data.setBusinessKey("myBusinessKey");
      data.setProcessDefinitionKey("oneTaskProcess");
      ObjectNode requestNode = (ObjectNode) objectMapper.readTree(objectMapper.writeValueAsString(data));
      httpPost.setEntity(new StringEntity(requestNode.toString()));
      response = executeRequest(httpPost, HttpStatus.SC_CREATED);
      responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);


      List<Task> tasks = taskService.createTaskQuery().processInstanceId(responseNode.get("id").asText()).list();
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, tasks.get(0).getId()));
      response = executeRequest(httpGet, HttpStatus.SC_OK);
      responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);

      assertTrue(responseNode.get("assignee") == null);
    } finally {
      // Always cleanup any created deployments, even if the test failed
      List<org.activiti.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list();
      for (org.activiti.engine.repository.Deployment deployment : deployments) {
        repositoryService.deleteDeployment(deployment.getId(), true);
      }
    }
  }
}
</code>

shailk
Champ in-the-making
Champ in-the-making
I have deployed the process xml using the activiti explorer and now the task owner is set as NULL and task assignee is also set as NULL.

I am using Activiti REST API to start the process instance.

I have initially tried using activiti:candidateUsers="kermit" but still owner is set as NULL hence not sure when will the owner be assigned to task.

PLease see attached BPM process definition after changes.

trademak
Star Contributor
Star Contributor
I think you are confused with terminology. With the BPMN XML you've provided a candidate group management is added to the "theTask" user task. You can now query on tasks for the candidate group management or with a candidate user that is part of the management group. A task owner is separate from this assignment logic.

Bets regards,

swapnil
Champ in-the-making
Champ in-the-making
Hi jbarrez ,

How should I get the deployed models from activiti bpmn into the my application using rest api. I am unable to get this, showing error as access denied.

-Thanks,
Swapnil