Upload Document in Zoho Writer
Table of Contents
Note:
- Each time the zoho.writer.uploadDocument integration task is executed, it triggers an API request in the back-end. This call is deducted from the external calls limit available for the service from which the task is executed, based on your pricing plan.
- Only actual executions that receive a response (whether success or failure) are counted, not the number of times the task appears in the script. For example, if zoho.writer.uploadDocument integration task is placed inside a for each task that iterates five times, the number of external calls consumed will be five, even though the task appears only once in the script.
Description
The zoho.writer.uploadDocument task is used to upload a document to Zoho Writer. This integration task is based on the Zoho Writer API - Create with content.
Syntax
<response> = zoho.writer.uploadDocument(<content>, <file_name>, <folder_id>, <password>, <connection>);
where:
| Params | Data type | Description |
| <response> | KEY-VALUE | The response returned by Zoho Writer. It represents the metadata of the uploaded document. |
| <content> | FILE | The document that will be uploaded. The supported document types are as follows:
Note:
|
| <file_name> | TEXT | The name in which the document will be uploaded. |
| <folder_id> | TEXT | The ID of the folder in Zoho Docs into which the document will be uploaded. Note: The folder ID can be obtained from the URL of the required folder in Zoho docs. The URL is in the following format: https://docs.zoho.com/home#folder/<folder_id> |
| <password> | TEXT | The password of the (protected) file that will be uploaded to Zoho Writer. Note: If the file that needs to be uploaded is not password-protected, the parameter will be passed empty. |
| <connection> | TEXT | The link name of the connection. Note:
|
Example
The following script uploads the document fetched from the web to Zoho Writer.
// Fetch a file from the web file_invoked = invokeUrl [ url: "http://homepages.inf.ed.ac.uk/neilb/TestWordDoc.doc" type: GET ]; // Upload the file to Zoho Writer response = zoho.writer.uploadDocument(file_invoked,"sample file","al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c","","writer_oauth_connection");
where:
responseThe KEY-VALUE response returned by Zoho Writer. It represents the metadata of the uploaded file.
file_invokedThe FILE that represents the file that is fetched from the web using the invokeUrl task, which will be uploaded in Zoho Writer.
"sample file"The TEXT that represents how many documents need to be fetched.
"al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c"The TEXT that represents the ID of the folder in Zoho docs into which the document will be uploaded.
"writer_oauth_connection"The TEXT that represents the name of the connection.
Response Format
Success Response
The success response will be returned in the following format:
{
"role": "OWNER",
"modified_time_ms": 1563945284888,
"owner_id": "58XXXX70",
"open_url": "https://writer.zoho.com/writer/open/cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"is_favourite": false,
"document_id": "cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"last_opened_time_ms": 1563945283271,
"thumbnail_url": "https://writer.zoho.com/writer/thumbnail/cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"type": "document",
"lock_info": {
"status": false
},
"document_name": "file_name",
"modified_time": "2019-07-24T05:14:44Z",
"library_id": 1,
"permissions": {
"can_trash": true,
"can_share": true,
"can_edit": true,
"can_lock": true,
"can_org_publish": true,
"can_read": true,
"can_discard_lock": false,
"can_publish": true,
"can_delete": false,
"can_restore": false,
"can_rename": true,
"can_favourite": true,
"can_download": true,
"can_unlock": false
},
"download_url": "https://writer.zoho.com/api/v1/download/cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"document_properties": "https://writer.zoho.com/api/v1/documents/cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"lastmodified_by": [
{
"email_id": "shawn.m@zylker.com",
"profile_photo": "https://contacts.zoho.com/file?t=user&ID=58XXXX70&fs=thumb",
"user_id": "58XXXX70",
"display_name": "Shawn"
}
],
"final_info": {
"status": false
},
"created_time": "2019-07-24T05:14:43Z",
"parent_folder_id": "al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c",
"collaboration_id": "1203XXXXXXXXXXX2220",
"last_opened_time": "2019-07-24T05:14:43Z",
"version_id": "7643XXXXXXXXXXX8022",
"created_by": "Shawn",
"version": "1.0",
"created_time_ms": 1563945283271,
"preview_url": "https://writer.zoho.com/writer/preview/cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"creator_id": "58XXXX170",
"permalink": "https://docs.zoho.com/file/cvqh0XXXXXXXXXXXXXXXXXXXXXXXXXXXb35f5",
"status": "active"
}
Failure Response
The failure response for uploading unsupported file type will be returned in the following format:
{
"error": {
"message": "The file you're trying to import seems to be in an unsupported content-type.",
"documentation_url": "https://www.zoho.com/writer/help/api/v1/general-errors.html",
"response_generated_time": 1563953458574,
"request_url": "https://writer.zoho.com/api/v1/documents",
"errorcode": "R1008"
}
}