返回介绍

15.7. Tasks

发布于 2023-09-17 23:40:35 字数 58080 浏览 0 评论 0 收藏 0

15.7.1. Get a task

GET runtime/tasks/{taskId}
Table 119. Get a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get.
Table 120. Get a task - Response codes
Response codeDescription
200Indicates the task was found and returned.
404Indicates the requested task was not found.

Success response body:

{
  "assignee" : "kermit",
  "createTime" : "2013-04-17T10:17:43.902+0000",
  "delegationState" : "pending",
  "description" : "Task description",
  "dueDate" : "2013-04-17T10:17:43.902+0000",
  "execution" : "http://localhost:8182/runtime/executions/5",
  "id" : "8",
  "name" : "My task",
  "owner" : "owner",
  "parentTask" : "http://localhost:8182/runtime/tasks/9",
  "priority" : 50,
  "processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4",
  "processInstance" : "http://localhost:8182/runtime/process-instances/5",
  "suspended" : false,
  "taskDefinitionKey" : "theTask",
  "url" : "http://localhost:8182/runtime/tasks/8",
  "tenantId" : null
}
  • delegationState: Delegation-state of the task, can be null, "pending" or "resolved".

15.7.2. List of tasks

GET runtime/tasks
Table 121. List of tasks - URL query parameters
ParameterRequiredValueDescription
nameNoStringOnly return tasks with the given name.
nameLikeNoStringOnly return tasks with a name like the given name.
descriptionNoStringOnly return tasks with the given description.
priorityNoIntegerOnly return tasks with the given priority.
minimumPriorityNoIntegerOnly return tasks with a priority greater than the given value.
maximumPriorityNoIntegerOnly return tasks with a priority lower than the given value.
assigneeNoStringOnly return tasks assigned to the given user.
assigneeLikeNoStringOnly return tasks assigned with an assignee like the given value.
ownerNoStringOnly return tasks owned by the given user.
ownerLikeNoStringOnly return tasks assigned with an owner like the given value.
unassignedNoBooleanOnly return tasks that are not assigned to anyone. If false is passed, the value is ignored.
delegationStateNoStringOnly return tasks that have the given delegation state. Possible values are pending and resolved.
candidateUserNoStringOnly return tasks that can be claimed by the given user. This includes both tasks where the user is an explicit candidate for and task that are claimable by a group that the user is a member of.
candidateGroupNoStringOnly return tasks that can be claimed by a user in the given group.
candidateGroupsNoStringOnly return tasks that can be claimed by a user in the given groups. Values split by comma.
involvedUserNoStringOnly return tasks in which the given user is involved.
taskDefinitionKeyNoStringOnly return tasks with the given task definition id.
taskDefinitionKeyLikeNoStringOnly return tasks with a given task definition id like the given value.
processInstanceIdNoStringOnly return tasks which are part of the process instance with the given id.
processInstanceBusinessKeyNoStringOnly return tasks which are part of the process instance with the given business key.
processInstanceBusinessKeyLikeNoStringOnly return tasks which are part of the process instance which has a business key like the given value.
processDefinitionIdNoStringOnly return tasks which are part of a process instance which has a process definition with the given id.
processDefinitionKeyNoStringOnly return tasks which are part of a process instance which has a process definition with the given key.
processDefinitionKeyLikeNoStringOnly return tasks which are part of a process instance which has a process definition with a key like the given value.
processDefinitionNameNoStringOnly return tasks which are part of a process instance which has a process definition with the given name.
processDefinitionNameLikeNoStringOnly return tasks which are part of a process instance which has a process definition with a name like the given value.
executionIdNoStringOnly return tasks which are part of the execution with the given id.
createdOnNoISO DateOnly return tasks which are created on the given date.
createdBeforeNoISO DateOnly return tasks which are created before the given date.
createdAfterNoISO DateOnly return tasks which are created after the given date.
dueOnNoISO DateOnly return tasks which are due on the given date.
dueBeforeNoISO DateOnly return tasks which are due before the given date.
dueAfterNoISO DateOnly return tasks which are due after the given date.
withoutDueDateNobooleanOnly return tasks which don’t have a due date. The property is ignored if the value is false.
excludeSubTasksNoBooleanOnly return tasks that are not a subtask of another task.
activeNoBooleanIf true, only return tasks that are not suspended (either part of a process that is not suspended or not part of a process at all). If false, only tasks that are part of suspended process instances are returned.
includeTaskLocalVariablesNoBooleanIndication to include task local variables in the result.
includeProcessVariablesNoBooleanIndication to include process variables in the result.
tenantIdNoStringOnly return tasks with the given tenantId.
tenantIdLikeNoStringOnly return tasks with a tenantId like the given value.
withoutTenantIdNoBooleanIf true, only returns tasks without a tenantId set. If false, the withoutTenantId parameter is ignored.
candidateOrAssignedNoStringSelect tasks that has been claimed or assigned to user or waiting to claim by user (candidate user or groups).
categoryNostringSelect tasks with the given category. Note that this is the task category, not the category of the process definition (namespace within the BPMN Xml).
Table 122. List of tasks - Response codes
Response codeDescription
200Indicates request was successful and the tasks are returned
400Indicates a parameter was passed in the wrong format or that delegationState has an invalid value (other than pending and resolved). The status-message contains additional information.

Success response body:

{
  "data": [
  {
    "assignee" : "kermit",
    "createTime" : "2013-04-17T10:17:43.902+0000",
    "delegationState" : "pending",
    "description" : "Task description",
    "dueDate" : "2013-04-17T10:17:43.902+0000",
    "execution" : "http://localhost:8182/runtime/executions/5",
    "id" : "8",
    "name" : "My task",
    "owner" : "owner",
    "parentTask" : "http://localhost:8182/runtime/tasks/9",
    "priority" : 50,
    "processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4",
    "processInstance" : "http://localhost:8182/runtime/process-instances/5",
    "suspended" : false,
    "taskDefinitionKey" : "theTask",
    "url" : "http://localhost:8182/runtime/tasks/8",
    "tenantId" : null
  }
  ],
  "total": 1,
  "start": 0,
  "sort": "name",
  "order": "asc",
  "size": 1
}

15.7.3. Query for tasks

POST query/tasks

Request body:

{
  "name" : "My task",
  "description" : "The task description",

  ...

  "taskVariables" : [
  {
    "name" : "myVariable",
    "value" : 1234,
    "operation" : "equals",
    "type" : "long"
  }
  ],

  "processInstanceVariables" : [
    {
     ...
    }
  ]
  ]
}

All supported JSON parameter fields allowed are exactly the same as the parameters found for getting a collection of tasks (except for candidateGroupIn which is only available in this POST task query REST service), but passed in as JSON-body arguments rather than URL-parameters to allow for more advanced querying and preventing errors with request-uri’s that are too long. On top of that, the query allows for filtering based on task and process variables. The taskVariables and processInstanceVariables are both JSON-arrays containing objects with the format as described here.

Table 123. Query for tasks - Response codes
Response codeDescription
200Indicates request was successful and the tasks are returned
400Indicates a parameter was passed in the wrong format or that delegationState has an invalid value (other than pending and resolved). The status-message contains additional information.

Success response body:

{
  "data": [
  {
    "assignee" : "kermit",
    "createTime" : "2013-04-17T10:17:43.902+0000",
    "delegationState" : "pending",
    "description" : "Task description",
    "dueDate" : "2013-04-17T10:17:43.902+0000",
    "execution" : "http://localhost:8182/runtime/executions/5",
    "id" : "8",
    "name" : "My task",
    "owner" : "owner",
    "parentTask" : "http://localhost:8182/runtime/tasks/9",
    "priority" : 50,
    "processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4",
    "processInstance" : "http://localhost:8182/runtime/process-instances/5",
    "suspended" : false,
    "taskDefinitionKey" : "theTask",
    "url" : "http://localhost:8182/runtime/tasks/8",
    "tenantId" : null
  }
  ],
  "total": 1,
  "start": 0,
  "sort": "name",
  "order": "asc",
  "size": 1
}

15.7.4. Update a task

PUT runtime/tasks/{taskId}

Body JSON:

{
  "assignee" : "assignee",
  "delegationState" : "resolved",
  "description" : "New task description",
  "dueDate" : "2013-04-17T13:06:02.438+02:00",
  "name" : "New task name",
  "owner" : "owner",
  "parentTaskId" : "3",
  "priority" : 20
}

All request values are optional. For example, you can only include the assignee attribute in the request body JSON-object, only updating the assignee of the task, leaving all other fields unaffected. When an attribute is explicitly included and is set to null, the task-value will be updated to null. Example: {"dueDate" : null} will clear the duedate of the task).

Table 124. Update a task - Response codes
Response codeDescription
200Indicates the task was updated.
404Indicates the requested task was not found.
409Indicates the requested task was updated simultaneously.

Success response body: see response for runtime/tasks/{taskId}.

15.7.5. Task actions

POST runtime/tasks/{taskId}

Complete a task - Body JSON:

{
  "action" : "complete",
  "variables" : []
}

Completes the task. Optional variable array can be passed in using the variables property. More information about the variable format can be found in the REST variables section. Note that the variable-scope that is supplied is ignored and the variables are set on the parent-scope unless a variable exists in a local scope, which is overridden in this case. This is the same behavior as the TaskService.completeTask(taskId, variables) invocation.

Note that also a transientVariables property is accepted as part of this json, that follows the same structure as the variables property.

Claim a task - Body JSON:

{
  "action" : "claim",
  "assignee" : "userWhoClaims"
}

Claims the task by the given assignee. If the assignee is null, the task is assigned to no-one, claimable again.

Delegate a task - Body JSON:

{
  "action" : "delegate",
  "assignee" : "userToDelegateTo"
}

Delegates the task to the given assignee. The assignee is required.

Resolve a task - Body JSON:


{
  "action" : "resolve"
}

Resolves the task delegation. The task is assigned back to the task owner (if any).

Table 125. Task actions - Response codes
Response codeDescription
200Indicates the action was executed.
400When the body contains an invalid value or when the assignee is missing when the action requires it.
404Indicates the requested task was not found.
409Indicates the action cannot be performed due to a conflict. Either the task was updates simultaneously or the task was claimed by another user, in case of the claim action.

Success response body: see response for runtime/tasks/{taskId}.

15.7.6. Delete a task

DELETE runtime/tasks/{taskId}?cascadeHistory={cascadeHistory}&deleteReason={deleteReason}
Table 126. >Delete a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to delete.
cascadeHistoryFalseBooleanWhether or not to delete the HistoricTask instance when deleting the task (if applicable). If not provided, this value defaults to false.
deleteReasonFalseStringReason why the task is deleted. This value is ignored when cascadeHistory is true.
Table 127. >Delete a task - Response codes
Response codeDescription
204Indicates the task was found and has been deleted. Response-body is intentionally empty.
403Indicates the requested task cannot be deleted because it’s part of a workflow.
404Indicates the requested task was not found.

15.7.7. Get all variables for a task

GET runtime/tasks/{taskId}/variables?scope={scope}
Table 128. Get all variables for a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get variables for.
scopeFalseStringScope of variables to be returned. When local, only task-local variables are returned. When global, only variables from the task’s parent execution-hierarchy are returned. When the parameter is omitted, both local and global variables are returned.
Table 129. Get all variables for a task - Response codes
Response codeDescription
200Indicates the task was found and the requested variables are returned.
404Indicates the requested task was not found.

Success response body:

[
  {
  "name" : "doubleTaskVar",
  "scope" : "local",
  "type" : "double",
  "value" : 99.99
  },
  {
  "name" : "stringProcVar",
  "scope" : "global",
  "type" : "string",
  "value" : "This is a ProcVariable"
  }



]

The variables are returned as a JSON array. Full response description can be found in the general REST-variables section.

15.7.8. Get a variable from a task

GET runtime/tasks/{taskId}/variables/{variableName}?scope={scope}
Table 130. Get a variable from a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get a variable for.
variableNameYesStringThe name of the variable to get.
scopeFalseStringScope of variable to be returned. When local, only task-local variable value is returned. When global, only variable value from the task’s parent execution-hierarchy are returned. When the parameter is omitted, a local variable will be returned if it exists, otherwise a global variable.
Table 131. Get a variable from a task - Response codes
Response codeDescription
200Indicates the task was found and the requested variables are returned.
404Indicates the requested task was not found or the task doesn’t have a variable with the given name (in the given scope). Status message provides additional information.

Success response body:

{
  "name" : "myTaskVariable",
  "scope" : "local",
  "type" : "string",
  "value" : "Hello my friend"
}

Full response body description can be found in the general REST-variables section.

15.7.9. Get the binary data for a variable

GET runtime/tasks/{taskId}/variables/{variableName}/data?scope={scope}
Table 132. Get the binary data for a variable - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get a variable data for.
variableNameYesStringThe name of the variable to get data for. Only variables of type binary and serializable can be used. If any other type of variable is used, a 404 is returned.
scopeFalseStringScope of variable to be returned. When local, only task-local variable value is returned. When global, only variable value from the task’s parent execution-hierarchy are returned. When the parameter is omitted, a local variable will be returned if it exists, otherwise a global variable.
Table 133. Get the binary data for a variable - Response codes
Response codeDescription
200Indicates the task was found and the requested variables are returned.
404Indicates the requested task was not found or the task doesn’t have a variable with the given name (in the given scope) or the variable doesn’t have a binary stream available. Status message provides additional information.

Success response body:

The response body contains the binary value of the variable. When the variable is of type binary, the content-type of the response is set to application/octet-stream, regardless of the content of the variable or the request accept-type header. In case of serializable, application/x-java-serialized-object is used as content-type.

15.7.10. Create new variables on a task

POST runtime/tasks/{taskId}/variables
Table 134. Create new variables on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to create the new variable for.

Request body for creating simple (non-binary) variables:

[
  {
  "name" : "myTaskVariable",
  "scope" : "local",
  "type" : "string",
  "value" : "Hello my friend"
  },
  {

  }
]

The request body should be an array containing one or more JSON-objects representing the variables that should be created.

  • name: Required name of the variable

  • scope: Scope of variable that is created. If omitted, local is assumed.

  • type: Type of variable that is created. If omitted, reverts to raw JSON-value type (string, boolean, integer or double).

  • value: Variable value.

More information about the variable format can be found in the REST variables section.

Success response body:

[
  {
  "name" : "myTaskVariable",
  "scope" : "local",
  "type" : "string",
  "value" : "Hello my friend"
  },
  {

  }
]
Table 135. Create new variables on a task - Response codes
Response codeDescription
201Indicates the variables were created and the result is returned.
400Indicates the name of a variable to create was missing or that an attempt is done to create a variable on a standalone task (without a process associated) with scope global or an empty array of variables was included in the request or request did not contain an array of variables. Status message provides additional information.
404Indicates the requested task was not found.
409Indicates the task already has a variable with the given name. Use the PUT method to update the task variable instead.

15.7.11. Create a new binary variable on a task

POST runtime/tasks/{taskId}/variables
Table 136. Create a new binary variable on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to create the new variable for.

Request body:

The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the variable. On top of that, the following additional form-fields can be present:

  • name: Required name of the variable.

  • scope: Scope of variable that is created. If omitted, local is assumed.

  • type: Type of variable that is created. If omitted, binary is assumed and the binary data in the request will be stored as an array of bytes.

Success response body:

{
  "name" : "binaryVariable",
  "scope" : "local",
  "type" : "binary",
  "value" : null,
  "valueUrl" : "http://.../runtime/tasks/123/variables/binaryVariable/data"
}
Table 137. Create a new binary variable on a task - Response codes
Response codeDescription
201Indicates the variable was created and the result is returned.
400Indicates the name of the variable to create was missing or that an attempt is done to create a variable on a standalone task (without a process associated) with scope global. Status message provides additional information.
404Indicates the requested task was not found.
409Indicates the task already has a variable with the given name. Use the PUT method to update the task variable instead.
415Indicates the serializable data contains an object for which no class is present in the JVM running the Flowable engine and therefore cannot be deserialized.

15.7.12. Update an existing variable on a task

PUT runtime/tasks/{taskId}/variables/{variableName}
Table 138. Update an existing variable on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to update the variable for.
variableNameYesStringThe name of the variable to update.

Request body for updating simple (non-binary) variables:

{
  "name" : "myTaskVariable",
  "scope" : "local",
  "type" : "string",
  "value" : "Hello my friend"
}
  • name: Required name of the variable

  • scope: Scope of variable that is updated. If omitted, local is assumed.

  • type: Type of variable that is updated. If omitted, reverts to raw JSON-value type (string, boolean, integer or double).

  • value: Variable value.

More information about the variable format can be found in the REST variables section.

Success response body:

{
  "name" : "myTaskVariable",
  "scope" : "local",
  "type" : "string",
  "value" : "Hello my friend"
}
Table 139. Update an existing variable on a task - Response codes
Response codeDescription
200Indicates the variables was updated and the result is returned.
400Indicates the name of a variable to update was missing or that an attempt is done to update a variable on a standalone task (without a process associated) with scope global. Status message provides additional information.
404Indicates the requested task was not found or the task doesn’t have a variable with the given name in the given scope. Status message contains additional information about the error.

15.7.13. Updating a binary variable on a task

PUT runtime/tasks/{taskId}/variables/{variableName}
Table 140. Updating a binary variable on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to update the variable for.
variableNameYesStringThe name of the variable to update.

Request body:

The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the variable. On top of that, the following additional form-fields can be present:

  • name: Required name of the variable.

  • scope: Scope of variable that is updated. If omitted, local is assumed.

  • type: Type of variable that is updated. If omitted, binary is assumed and the binary data in the request will be stored as an array of bytes.

Success response body:

{
  "name" : "binaryVariable",
  "scope" : "local",
  "type" : "binary",
  "value" : null,
  "valueUrl" : "http://.../runtime/tasks/123/variables/binaryVariable/data"
}
Table 141. Updating a binary variable on a task - Response codes
Response codeDescription
200Indicates the variable was updated and the result is returned.
400Indicates the name of the variable to update was missing or that an attempt is done to update a variable on a standalone task (without a process associated) with scope global. Status message provides additional information.
404Indicates the requested task was not found or the variable to update doesn’t exist for the given task in the given scope.
415Indicates the serializable data contains an object for which no class is present in the JVM running the Flowable engine and therefore cannot be deserialized.

15.7.14. Delete a variable on a task

DELETE runtime/tasks/{taskId}/variables/{variableName}?scope={scope}
Table 142. Delete a variable on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task the variable to delete belongs to.
variableNameYesStringThe name of the variable to delete.
scopeNoStringScope of variable to delete in. Can be either local or global. If omitted, local is assumed.
Table 143. Delete a variable on a task - Response codes
Response codeDescription
204Indicates the task variable was found and has been deleted. Response-body is intentionally empty.
404Indicates the requested task was not found or the task doesn’t have a variable with the given name. Status message contains additional information about the error.

15.7.15. Delete all local variables on a task

DELETE runtime/tasks/{taskId}/variables
Table 144. Delete all local variables on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task the variable to delete belongs to.
Table 145. Delete all local variables on a task - Response codes
Response codeDescription
204Indicates all local task variables have been deleted. Response-body is intentionally empty.
404Indicates the requested task was not found.

15.7.16. Get all identity links for a task

GET runtime/tasks/{taskId}/identitylinks
Table 146. Get all identity links for a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the identity links for.
Table 147. Get all identity links for a task - Response codes
Response codeDescription
200Indicates the task was found and the requested identity links are returned.
404Indicates the requested task was not found.

Success response body:

[
  {
  "userId" : "kermit",
  "groupId" : null,
  "type" : "candidate",
  "url" : "http://localhost:8081/flowable-rest/service/runtime/tasks/100/identitylinks/users/kermit/candidate"
  },
  {
  "userId" : null,
  "groupId" : "sales",
  "type" : "candidate",
  "url" : "http://localhost:8081/flowable-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
  },

  ...
]

15.7.17. Get all identitylinks for a task for either groups or users

GET runtime/tasks/{taskId}/identitylinks/users
GET runtime/tasks/{taskId}/identitylinks/groups

Returns only identity links targeting either users or groups. Response body and status-codes are exactly the same as when getting the full list of identity links for a task.

15.7.18. Get a single identity link on a task

GET runtime/tasks/{taskId}/identitylinks/{family}/{identityId}/{type}
Table 148. Get all identitylinks for a task for either groups or users - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task .
familyYesStringEither groups or users, depending on what kind of identity is targeted.
identityIdYesStringThe id of the identity.
typeYesStringThe type of identity link.
Table 149. Get all identitylinks for a task for either groups or users - Response codes
Response codeDescription
200Indicates the task and identity link was found and returned.
404Indicates the requested task was not found or the task doesn’t have the requested identityLink. The status contains additional information about this error.

Success response body:

{
  "userId" : null,
  "groupId" : "sales",
  "type" : "candidate",
  "url" : "http://localhost:8081/flowable-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
}

15.7.19. Create an identity link on a task

POST runtime/tasks/{taskId}/identitylinks
Table 150. Create an identity link on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task .

Request body (user):

{
  "userId" : "kermit",
  "type" : "candidate",
}

Request body (group):

{
  "groupId" : "sales",
  "type" : "candidate",
}
Table 151. Create an identity link on a task - Response codes
Response codeDescription
201Indicates the task was found and the identity link was created.
404Indicates the requested task was not found or the task doesn’t have the requested identityLink. The status contains additional information about this error.

Success response body:

{
  "userId" : null,
  "groupId" : "sales",
  "type" : "candidate",
  "url" : "http://localhost:8081/flowable-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
}

15.7.20. Delete an identity link on a task

DELETE runtime/tasks/{taskId}/identitylinks/{family}/{identityId}/{type}
Table 152. Delete an identity link on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task.
familyYesStringEither groups or users, depending on what kind of identity is targeted.
identityIdYesStringThe id of the identity.
typeYesStringThe type of identity link.
Table 153. Delete an identity link on a task - Response codes
Response codeDescription
204Indicates the task and identity link were found and the link has been deleted. Response-body is intentionally empty.
404Indicates the requested task was not found or the task doesn’t have the requested identityLink. The status contains additional information about this error.

15.7.21. Create a new comment on a task

POST runtime/tasks/{taskId}/comments
Table 154. Create a new comment on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to create the comment for.

Request body:

{
  "message" : "This is a comment on the task.",
  "saveProcessInstanceId" : true
}

Parameter saveProcessInstanceId is optional, if true save process instance id of task with comment.

Success response body:

{
  "id" : "123",
  "taskUrl" : "http://localhost:8081/flowable-rest/service/runtime/tasks/101/comments/123",
  "processInstanceUrl" : "http://localhost:8081/flowable-rest/service/history/historic-process-instances/100/comments/123",
  "message" : "This is a comment on the task.",
  "author" : "kermit",
  "time" : "2014-07-13T13:13:52.232+08:00"
  "taskId" : "101",
  "processInstanceId" : "100"
}
Table 155. Create a new comment on a task - Response codes
Response codeDescription
201Indicates the comment was created and the result is returned.
400Indicates the comment is missing from the request.
404Indicates the requested task was not found.

15.7.22. Get all comments on a task

GET runtime/tasks/{taskId}/comments
Table 156. Get all comments on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the comments for.

Success response body:

[
  {
  "id" : "123",
  "taskUrl" : "http://localhost:8081/flowable-rest/service/runtime/tasks/101/comments/123",
  "processInstanceUrl" : "http://localhost:8081/flowable-rest/service/history/historic-process-instances/100/comments/123",
  "message" : "This is a comment on the task.",
  "author" : "kermit"
  "time" : "2014-07-13T13:13:52.232+08:00"
  "taskId" : "101",
  "processInstanceId" : "100"
  },
  {
  "id" : "456",
  "taskUrl" : "http://localhost:8081/flowable-rest/service/runtime/tasks/101/comments/456",
  "processInstanceUrl" : "http://localhost:8081/flowable-rest/service/history/historic-process-instances/100/comments/456",
  "message" : "This is another comment on the task.",
  "author" : "gonzo",
  "time" : "2014-07-13T13:13:52.232+08:00"
  "taskId" : "101",
  "processInstanceId" : "100"
  }
]
Table 157. Get all comments on a task - Response codes
Response codeDescription
200Indicates the task was found and the comments are returned.
404Indicates the requested task was not found.

15.7.23. Get a comment on a task

GET runtime/tasks/{taskId}/comments/{commentId}
Table 158. Get a comment on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the comment for.
commentIdYesStringThe id of the comment.

Success response body:

{
  "id" : "123",
  "taskUrl" : "http://localhost:8081/flowable-rest/service/runtime/tasks/101/comments/123",
  "processInstanceUrl" : "http://localhost:8081/flowable-rest/service/history/historic-process-instances/100/comments/123",
  "message" : "This is a comment on the task.",
  "author" : "kermit",
  "time" : "2014-07-13T13:13:52.232+08:00"
  "taskId" : "101",
  "processInstanceId" : "100"
}
Table 159. Get a comment on a task - Response codes
Response codeDescription
200Indicates the task and comment were found and the comment is returned.
404Indicates the requested task was not found or the tasks doesn’t have a comment with the given ID.

15.7.24. Delete a comment on a task

DELETE runtime/tasks/{taskId}/comments/{commentId}
Table 160. Delete a comment on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to delete the comment for.
commentIdYesStringThe id of the comment.
Table 161. Delete a comment on a task - Response codes
Response codeDescription
204Indicates the task and comment were found and the comment is deleted. Response body is left empty intentionally.
404Indicates the requested task was not found or the tasks doesn’t have a comment with the given ID.

15.7.25. Get all events for a task

GET runtime/tasks/{taskId}/events
Table 162. Get all events for a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the events for.

Success response body:

[
  {
  "action" : "AddUserLink",
  "id" : "4",
  "message" : [ "gonzo", "contributor" ],
  "taskUrl" : "http://localhost:8182/runtime/tasks/2",
  "time" : "2013-05-17T11:50:50.000+0000",
  "url" : "http://localhost:8182/runtime/tasks/2/events/4",
  "userId" : null
  }

]
Table 163. Get all events for a task - Response codes
Response codeDescription
200Indicates the task was found and the events are returned.
404Indicates the requested task was not found.

15.7.26. Get an event on a task

GET runtime/tasks/{taskId}/events/{eventId}
Table 164. Get an event on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the event for.
eventIdYesStringThe id of the event.

Success response body:

{
  "action" : "AddUserLink",
  "id" : "4",
  "message" : [ "gonzo", "contributor" ],
  "taskUrl" : "http://localhost:8182/runtime/tasks/2",
  "time" : "2013-05-17T11:50:50.000+0000",
  "url" : "http://localhost:8182/runtime/tasks/2/events/4",
  "userId" : null
}
Table 165. Get an event on a task - Response codes
Response codeDescription
200Indicates the task and event were found and the event is returned.
404Indicates the requested task was not found or the tasks doesn’t have an event with the given ID.

15.7.27. Create a new attachment on a task, containing a link to an external resource

POST runtime/tasks/{taskId}/attachments
Table 166. Create a new attachment on a task, containing a link to an external resource - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to create the attachment for.

Request body:

{
  "name":"Simple attachment",
  "description":"Simple attachment description",
  "type":"simpleType",
  "externalUrl":"http://flowable.org"
}

Only the attachment name is required to create a new attachment.

Success response body:

{
  "id":"3",
  "url":"http://localhost:8182/runtime/tasks/2/attachments/3",
  "name":"Simple attachment",
  "description":"Simple attachment description",
  "type":"simpleType",
  "taskUrl":"http://localhost:8182/runtime/tasks/2",
  "processInstanceUrl":null,
  "externalUrl":"http://flowable.org",
  "contentUrl":null
}
Table 167. Create a new attachment on a task, containing a link to an external resource - Response codes
Response codeDescription
201Indicates the attachment was created and the result is returned.
400Indicates the attachment name is missing from the request.
404Indicates the requested task was not found.

15.7.28. Create a new attachment on a task, with an attached file

POST runtime/tasks/{taskId}/attachments
Table 168. Create a new attachment on a task, with an attached file - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to create the attachment for.

Request body:

The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the variable. On top of that, the following additional form-fields can be present:

  • name: Required name of the variable.

  • description: Description of the attachment, optional.

  • type: Type of attachment, optional. Supports any arbitrary string or a valid HTTP content-type.

Success response body:

{
	"id":"5",
	"url":"http://localhost:8182/runtime/tasks/2/attachments/5",
  "name":"Binary attachment",
  "description":"Binary attachment description",
  "type":"binaryType",
  "taskUrl":"http://localhost:8182/runtime/tasks/2",
  "processInstanceUrl":null,
  "externalUrl":null,
  "contentUrl":"http://localhost:8182/runtime/tasks/2/attachments/5/content"
}
Table 169. Create a new attachment on a task, with an attached file - Response codes
Response codeDescription
201Indicates the attachment was created and the result is returned.
400Indicates the attachment name is missing from the request or no file was present in the request. The error-message contains additional information.
404Indicates the requested task was not found.

15.7.29. Get all attachments on a task

GET runtime/tasks/{taskId}/attachments
Table 170. Get all attachments on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the attachments for.

Success response body:

[
  {
  "id":"3",
  "url":"http://localhost:8182/runtime/tasks/2/attachments/3",
  "name":"Simple attachment",
  "description":"Simple attachment description",
  "type":"simpleType",
  "taskUrl":"http://localhost:8182/runtime/tasks/2",
  "processInstanceUrl":null,
  "externalUrl":"http://flowable.org",
  "contentUrl":null
  },
  {
  "id":"5",
  "url":"http://localhost:8182/runtime/tasks/2/attachments/5",
  "name":"Binary attachment",
  "description":"Binary attachment description",
  "type":"binaryType",
  "taskUrl":"http://localhost:8182/runtime/tasks/2",
  "processInstanceUrl":null,
  "externalUrl":null,
  "contentUrl":"http://localhost:8182/runtime/tasks/2/attachments/5/content"
  }
]
Table 171. Get all attachments on a task - Response codes
Response codeDescription
200Indicates the task was found and the attachments are returned.
404Indicates the requested task was not found.

15.7.30. Get an attachment on a task

GET runtime/tasks/{taskId}/attachments/{attachmentId}
Table 172. Get an attachment on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get the attachment for.
attachmentIdYesStringThe id of the attachment.

Success response body:

{
  "id":"5",
  "url":"http://localhost:8182/runtime/tasks/2/attachments/5",
  "name":"Binary attachment",
  "description":"Binary attachment description",
  "type":"binaryType",
  "taskUrl":"http://localhost:8182/runtime/tasks/2",
  "processInstanceUrl":null,
  "externalUrl":null,
  "contentUrl":"http://localhost:8182/runtime/tasks/2/attachments/5/content"
}
  • externalUrl - contentUrl:In case the attachment is a link to an external resource, the externalUrl contains the URL to the external content. If the attachment content is present in the Flowable engine, the contentUrl will contain an URL where the binary content can be streamed from.

  • type:Can be any arbitrary value. When a valid formatted media-type (e.g. application/xml, text/plain) is included, the binary content HTTP response content-type will be set the the given value.

Table 173. Get an attachment on a task - Response codes
Response codeDescription
200Indicates the task and attachment were found and the attachment is returned.
404Indicates the requested task was not found or the tasks doesn’t have a attachment with the given ID.

15.7.31. Get the content for an attachment

GET runtime/tasks/{taskId}/attachment/{attachmentId}/content
Table 174. Get the content for an attachment - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to get a variable data for.
attachmentIdYesStringThe id of the attachment, a 404 is returned when the attachment points to an external URL rather than content attached in Flowable.
Table 175. Get the content for an attachment - Response codes
Response codeDescription
200Indicates the task and attachment was found and the requested content is returned.
404Indicates the requested task was not found or the task doesn’t have an attachment with the given id or the attachment doesn’t have a binary stream available. Status message provides additional information.

Success response body:

The response body contains the binary content. By default, the content-type of the response is set to application/octet-stream unless the attachment type contains a valid Content-type.

15.7.32. Delete an attachment on a task

DELETE runtime/tasks/{taskId}/attachments/{attachmentId}
Table 176. Delete an attachment on a task - URL parameters
ParameterRequiredValueDescription
taskIdYesStringThe id of the task to delete the attachment for.
attachmentIdYesStringThe id of the attachment.
Table 177. Delete an attachment on a task - Response codes
Response codeDescription
204Indicates the task and attachment were found and the attachment is deleted. Response body is left empty intentionally.
404Indicates the requested task was not found or the tasks doesn’t have a attachment with the given ID.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文