Choose where you’d like to start

Upload Document in Zoho Writer

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:
ParamsData typeDescription

<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:

  • .doc
  • .docx
  • .rtf
  • .odt
  • .html
  • .txt
  • .htm
  • .zdoc
  • .zip
Note:
  • The file is invoked from the cloud using the invokeUrl task.
  • In Zoho Creator, the file uploaded in the file upload field can also be used as value for this parameter.

<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:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory in order for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter until you manually delete the authtoken from accounts.
  • Add relevant scopes mentioned in Zoho Writer API while creating the connection.
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

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:

response
The KEY-VALUE response returned by Zoho Writer. It represents the metadata of the uploaded file.
file_invoked
The 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"
      }
      }

Related Links

Get Started Now

Execute