Get External Tasks (POST)

Queries for external tasks that fulfill given parameters in the form of a JSON object. This method is slightly more powerful than the Get External Tasks method because it allows to specify a hierarchical result sorting.

Method

POST /external-task

Parameters

Query Parameters

Name Description
firstResult Pagination of results. Specifies the index of the first result to return.
maxResults Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left.

Request Body

A JSON object with the following properties:

Name Description
externalTaskId Filter by an external task's id.
topicName Filter by an external task topic.
workerId Filter by the id of the worker that the task was most recently locked by.
locked Only include external tasks that are currently locked (i.e., they have a lock time and it has not expired). Value may only be true, as false matches any external task.
notLocked Only include external tasks that are currently not locked (i.e., they have no lock or it has expired). Value may only be true, as false matches any external task.
withRetriesLeft Only include external tasks that have a positive (> 0) number of retries (or null). Value may only be true, as false matches any external task.
noRetriesLeft Only include external tasks that have 0 retries. Value may only be true, as false matches any external task.
lockExpirationAfter Restrict to external tasks that have a lock that expires after a given date. By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
lockExpirationBefore Restrict to external tasks that have a lock that expires before a given date. By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
activityId Filter by the id of the activity that an external task is created for.
activityIdIn Filter by the comma-separated list of ids of the activities that an external task is created for.
executionId Filter by the id of the execution that an external task belongs to.
processInstanceId Filter by the id of the process instance that an external task belongs to.
processDefinitionId Filter by the id of the process definition that an external task belongs to.
tenantIdIn Filter by a comma-separated list of tenant ids. An external task must have one of the given tenant ids.
active Only include active tasks. Value may only be true, as false matches any external task.
suspended Only include suspended tasks. Value may only be true, as false matches any external task.
priorityHigherThanOrEquals Only include jobs with a priority higher than or equal to the given value. Value must be a valid long value.
priorityLowerThanOrEquals Only include jobs with a priority lower than or equal to the given value. Value must be a valid long value.
sorting

A JSON array of criteria to sort the result by. Each element of the array is a JSON object that specifies one ordering. The position in the array identifies the rank of an ordering, i.e., whether it is primary, secondary, etc. The ordering objects have the following properties:

Name Description
sortBy Mandatory. Sort the results lexicographically by a given criterion. Valid values are id, lockExpirationTime, processInstanceId, processDefinitionId, processDefinitionKey, taskPriority and tenantId.
sortOrder Mandatory. Sort the results in a given order. Values may be asc for ascending order or desc for descending order.

* For further information, please see the documentation.

Result

A JSON array of external task objects. Each external task object has the following properties:

Name Value Description
activityId String The id of the activity that this external task belongs to.
activityInstanceId String The id of the activity instance that the external task belongs to.
errorMessage String The full error message submitted with the latest reported failure executing this task;
null if no failure was reported previously or if no error message was submitted
errorDetails String The error details submitted with the latest reported failure executing this task.
null if no failure was reported previously or if no error details was submitted
executionId String The id of the execution that the external task belongs to.
id String The id of the external task.
lockExpirationTime String The date that the task's most recent lock expires or has expired.
processDefinitionId String The id of the process definition the external task is defined in.
processDefinitionKey String The key of the process definition the external task is defined in.
processInstanceId String The id of the process instance the external task belongs to.
tenantId String The id of the tenant the external task belongs to.
retries Number The number of retries the task currently has left.
suspended Boolean A flag indicating whether the external task is suspended or not.
workerId String The id of the worker that posesses or posessed the most recent lock.
topicName String The topic name of the external task.
priority Number The priority of the external task.
businessKey String The business key of the process instance the external task belongs to.

Response Codes

Code Media type Description
200 application/json Request successful.
400 application/json Returned if some of the query parameters are invalid, for example if a sortOrder parameter is supplied, but no sortBy. See the Introduction for the error response format.

Example

Request

POST /external-task

Request Body:

{
  "processDefinitionId":"aProcessDefinitionId",
  "sorting":
      [{"sortBy": "processDefinitionKey",
      "sortOrder": "asc"
      },
      {"sortBy": "lockExpirationTime",
      "sortOrder": "desc"
      }]
}

Response

Status 200.

[{
  "activityId": "anActivityId",
  "activityInstanceId": "anActivityInstanceId",
  "errorMessage": "anErrorMessage",
  "errorDetails": "anErrorDetails",
  "executionId": "anExecutionId",
  "id": "anExternalTaskId",
  "lockExpirationTime": "2015-10-06T16:34:42.000+0200",
  "processDefinitionId": "aProcessDefinitionId",
  "processDefinitionKey": "aProcessDefinitionKey",
  "processInstanceId": "aProcessInstanceId",
  "tenantId": null,
  "retries": 3,
  "suspended": false,
  "workerId": "aWorkerId",
  "topicName": "aTopic",
  "priority": 9,
  "businessKey": "aBusinessKey"
},
{
  "activityId": "anotherActivityId",
  "activityInstanceId": "anotherActivityInstanceId",
  "errorMessage": "anotherErrorMessage",
  "errorDetails": "anotherErrorDetails",
  "executionId": "anotherExecutionId",
  "id": "anotherExternalTaskId",
  "lockExpirationTime": "2015-10-06T16:34:42.000+0200",
  "processDefinitionId": "aProcessDefinitionId",
  "processDefinitionKey": "anotherProcessDefinitionKey",
  "processInstanceId": "anotherProcessInstanceId",
  "tenantId": null,
  "retries": 1,
  "suspended": false,
  "workerId": "aWorkerId",
  "topicName": "aTopic",
  "priority": 3,
  "businessKey": "aBusinessKey"
}]

On this Page: