Skip to main content

How to upload attachments via workflow or API


Writing files to a worksheet can be done through workflow or API. For workflows, only URLs are supported; for APIs, both URLs and Base64 are supported.

I. Upload files via workflow

The workflows triggered by Webhook can receive external data to add to the worksheet or update data in the worksheet, while also allowing for file uploads.

In the "Add Record" or "Update Record" nodes in the workflow, the input to the file field must be a Json string consisting of one or more file download URLs.

  • When uploading a file, the format is: url1 or ["url1"], for example: https://help.nocoly.com/logo/logo.png or ["https://help.nocoly.com/logo/logo.png"]

  • When uploading multiple files, it must be in the format of : ["url1", "url2"], for example: ["https://help.nocoly.com/logo/logo.png","https://help.nocoly.com/file/crm.xlsx"].

If uploading files through the "Add Record" node or "Update Record" node, choose a text field as the file field.

For example, in the worksheet below, write the download link of the file to a text field "Download Link" first, and then through the workflow, automatically download and save it to the "File" field.

1. Set the trigger node

3. Test

To write the download link of the file into the field, you can directly copy the following content (including []):

["https://help.nocoly.com/logo/logo.png","https://help.nocoly.com/file/crm.xlsx"]

II. Upload files via API

For more details, check out the following content.

Parameter Introduction

{
controlId: //ID of the file control;
"value": //Links to external files. If there are multiple files, separate them with commas;
"editType":0 //Data update type. 0-Overwrite existing file; 1-Add current file (Default: 0-Overwrite. This parameter may not be passed for new records, but is required for updating records);
"valueType":1//Ways to upload files. 1=Links to external files; 2=file stream byte-encoded base64 string (Default: 1. When it is 1, the external link is placed in the value parameter; when it is 2, the file stream base64 information is placed in the controlFiles parameter below);

"controlFiles":[{
"baseFile":"QABAAQQQAAG9nCwAAAA==", //base64 string (file stream byte encoding);
"fileName":"File name with extension.xlsx" //File name with extension;
}]
}

URL - Example

  • If uploading 1 file, the value assigned to the attachment field is "url1", for example, "https://help.nocoly.com/logo/logo.png"

  • If uploading multiple files, the format is "url1,url2", for example, "https://help.nocoly.com/logo/logo.png,https://help.nocoly.com/logo/logo.png".

{
"appKey": "0a265**3a155de01",
"sign": "ZmFkZjExMmNlY***NDA4ZjI5N2YxZDEwMjlkZWNkOTRkNTg5NjBkYWQzOTYxYjgwMWM4ZDg5NzYwOGMxZjZmOA==",
"worksheetId": "61111f2eb94**ac37d7d6e",
"controls": [
{
"controlId": "61111f2eb94aac37d7d6f",
"value": "Test"
},
{
"controlId":"61111f2eb10caac37d7d71",
"value":"https://help.nocoly.com/logo/logo.png",
"editType":0,
"valueType":1//Setting1
}
]
}

Base64 File Stream - Example

{
"appKey": "0a265**3a155de01",
"sign": "ZmFkZjExMmNlY***NDA4ZjI5N2YxZDEwMjlkZWNkOTRkNTg5NjBkYWQzOTYxYjgwMWM4ZDg5NzYwOGMxZjZmOA==",
"worksheetId": "61111f2eb94**ac37d7d6e",
"controls": [
{
"controlId": "61111f2eb94aac37d7d6f",
"value": "Test"
},
{
"controlId":"61111f2eb10caac37d7d71",
"editType":0,
"valueType":2,//Setting2
"controlFiles":[
{
"baseFile":"QABAAQQQAAG9nCwAAAA==",
"fileName":"File name with extension.xlsx"
}]
}
]
}

Possible Timeout Issues

If you are using the API for batch adding records and need to upload files at the same time, you may encounter timeout issues because it will wait for the file upload to be completed before returning a successful status.

Suggested method

First write the URL of the files into a text field to ensure that basic data is written quickly, and then process the file upload through a workflow. See the example above.

III. Comparison of writing files via API and workflow

The main difference lies in the format of the file addresses.

  • The format in the workflow is: ["url1", "url2"].

  • The format in the API is: "url1,url2".

IV. URL format

  • The URL of the file must be accessible to the platform server.

  • Files can be directly downloaded and saved through the URL.

  • The URL must end with the file extension.


Have questions about this article? Send us feedback