How to get back tasks?

My goal is to add an attachment to the task using the API (document, picture, etc). A user will see it at a later date.

Suppose I am going thru a workflow. I search by businessKey.

I am at the 10th task. Tasks are marked completed.

I want to retrieve the 5th task and see an attachment or the form data.Or, I may want to get a list of all completed tasks.

Do I need to keep track of task UUIDs to do this? When I do a GET the next uncompleted task shows up. Can I query by completed status>?

Thanks

@lenny_h are you using camunda rest api or java api?

Using camunda rest api you can query for completed tasks from history. You can filter the completed tasks with various attributes given in this docs page as json payload.
Refer this: https://docs.camunda.org/manual/7.11/reference/rest/history/task/post-task-query/

Camunda rest api to query completed tasks: POST /history/task

Sample json request to query for completed tasks:

{
  "processDefinitionKey" : "< processDefinitionKey> "
  "finished" : true,
  "processInstanceBusinessKey" : "< businesskey>"
}

You will get a JSON array of historic task objects.

To retrieve the attachment from completed tasks refer this page: https://docs.camunda.org/manual/7.11/reference/rest/history/variable-instance/get-variable-instance-binary/

GET /history/variable-instance/{id}/data

Attachments retieved are of type Byte Stream.

To retrieve attachments from active tasks: https://docs.camunda.org/manual/7.11/reference/rest/task/attachment/get-task-attachment-data/

GET /task/{id}/attachment/{attachmentId}/data

Thanks, this all works very well with my vue js app!
Is there a size limit I should be aware of for attachments? Hopefully things will be below 1GB!

Hi @lenny_h I hope it will be 10MB, maybe you can set the filesize using attribute in appplication.properties file (Spring Boot)

spring.http.multipart.max-file-size=1GB

If you are using tomcat distribution, that can be configured in TOMCAT_HOME/conf/server.xml file:

<Connector port ="8080" 
 protocol="HTTP/1.1"
 connectionTimeout="20000"
 redirectPort="8443"
 maxSwallowSize= "1GB"/>

I have not tested myself uploading huge file to camunda.

In general, process variables are not suited to store large files and you are going to observe rather bad performance. I recommend you to store such data in a separate storage like filesystem, AWS S3 or other cloud storage,etc. and only reference it from your process instance.

I agree, this is true for any website. We may also consider a separate keystore to hold the large resources as well. The metadata for attachments is very flexible.

@lenny_h i agree the point on metadata, so you can either store the metadata as process variables along with file reference or when you store the file in cloud, you can able to store the metadata in the cloud itself, while reading the file from cloud(AWS S3) in specific activity you can able to retrieve the metadata as well.