REST API > How do I upload or attach a file (asset) to a task (task field)

There are two types of file origins you can attach to a task (task field):

A. Local file (asset) - needs an upload, and then an attachment to the task field
B. External / URL based file (asset) - needs only attachment to the task field

Here's a step by step procedure for attaching the file (asset) on case basis.

A. Local file / asset

Here, we need to first upload the file to Tallyfy file server, and then attach the file to the task field):

1. Upload the file to our file system / storage via an API client (Postman etc.) using the call below:

POST, "https://api.tallyfy.com/organizations/ <your-organization-id-here>/file" with request type "form-data" and key-values as below:
i) " name": type "file" - Upload file here
ii) " uploaded_from": type "text" - Add Organization ID here
iii) " subject_type": type "text" - Add text "Run" here
iv) " step_id": type "text" - Add Step ID here
v) " checklist_id": type "text" - Add Checklist ID here
vi) " subject_id": type "text" - Add Run ID here

Please also set the request header " Accept" to "application/json, text/plain, */*" (Please also make sure that auth bearer token is included in the request headers)

You'll receive response of the request something like this: ( Let's call this response -- var fileData)

Example of the complete POST request is shown below:

2. Next, attach the above file (asset) data to the task field:

PUT, https://api.tallyfy.com/organizations/<your-organization-id-here>/runs/<run_id_here>/tasks/<task_id_here>


Request Payload:

{
  "taskdata": {
    " <capture_id_here_(field_id)>": [
      " fileData.data" (object from the above file data response)
    ]
  }
}

Example of the request payload is shown below:

Example of the complete PUT request is shown below:

(Please also make sure that auth bearer token is included in the request headers)

This should update the task field with the uploaded file.



B)  External / URL based

Here, we just need to attach the file to the task field:

1. Attach the file data to the task field:

PUT, https://api.tallyfy.com/organizations/<your-organization-id-here>/runs/<run_id_here>/tasks/<task_id_here>


Request Payload:

{
  "taskdata": {
    " <capture_id_here_(field_id)>": [
      {
        "filename": " <file_name_here>",
        "source": "url",
        "subject": {
          "id": " <run_id_here>",
          "type": " Run" (keep this as-is)
        },
        "uploaded_from": " <org_id_here>",
        "url": " <external_file_URL_here>"
      }
    ]
  }
}


Example of the request payload here:

(Please also make sure that auth bearer token is included in the request headers)

Example of the complete PUT request is shown below:

This should update the task field with the external file.


By following any of the above steps, depending upon your use-case, you should be able to attach a file to a task field.

Please do let us know if you have any questions.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us