Queries for the number of process instances that fulfill the given parameters.This method takes the same message body as the Get Instances (POST)and therefore it is slightly more powerful than the Get Instance Count method.

Method

POST /process-instance/count

Parameters

Request Body

A JSON object with the following properties:

Name Description
processInstanceIds Filter by a list of process instance ids. Must be a JSON array of Strings.
businessKey Filter by process instance business key.
businessKeyLike Filter by process instance business key that the parameter is a substring of.
caseInstanceId Filter by case instance id.
processDefinitionId Filter by the process definition the instances run on.
processDefinitionKey Filter by the key of the process definition the instances run on.
deploymentId Filter by the deployment the id belongs to.
superProcessInstance Restrict query to all process instances that are sub process instances of the given process instance. Takes a process instance id.
subProcessInstance Restrict query to all process instances that have the given process instance as a sub process instance. Takes a process instance id.
superCaseInstance Restrict query to all process instances that are sub process instances of the given case instance. Takes a case instance id.
subCaseInstance Restrict query to all process instances that have the given case instance as a sub case instance. Takes a case instance id.
active Only include active process instances. Value may only be true, as false is the default behavior.
suspended Only include suspended process instances. Value may only be true, as false is the default behavior.
incidentId Filter by the incident id.
incidentType Filter by the incident type. See the User Guide for a list of incident types.
incidentMessage Filter by the incident message. Exact match.
incidentMessageLike Filter by the incident message that the parameter is a substring of.
tenantIdIn Filter by a list of tenant ids. A process instance must have one of the given tenant ids. Must be a JSON array of Strings.
withoutTenantId Only include process instances which belong to no tenant. Value may only be true, as false is the default behavior.
activityIdIn Filter by a list of activity ids. A process instance must currently wait in a leaf activity with one of the given activity ids.
rootProcessInstances Restrict the query to all process instances that are top level process instances.
variables A JSON array to only include process instances that have variables with certain values. The array consists of objects with the three properties key, operator and value. key (String) is the variable name, operator (String) is the comparison operator to be used and value the variable value. value may be String, Number or Boolean. Valid operator values are: eq - equal to; neq - not equal to; gt - greater than; gteq - greater than or equal to; lt - lower than; lteq - lower than or equal to; like.

Result

A JSON object that contains the count as the only property.

Name Value Description
count Number The number of matching process instances.

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, or if an invalid operator for variable comparison is used. See the Introduction for the error response format.

Example

Request

POST /process-instance/count

Request Body:

  1. {"variables":
  2. [{"name": "myVariable",
  3. "operator": "eq",
  4. "value": "camunda"
  5. },
  6. {"name": "mySecondVariable",
  7. "operator": "neq",
  8. "value": 124}],
  9. "processDefinitionId":"aProcessDefinitionId"}

Response

  1. {"count": 1}

原文: https://docs.camunda.org/manual/7.9/reference/rest/process-instance/post-query-count/