Share Documents in Zoho Writer
Table of Contents
Description
The zoho.writer.shareDocument task is used to share a Zoho Writer document owned or co-owned by you with other users.
Syntax
<response> = zoho.writer.shareDocument(<document_id>, <email_id>, <role>, <type>, <connection>);
Params | Data type | Description |
<response> | KEY-VALUE | The response returned by Zoho Writer. It represents the details of the user who shares the document and with whom the document is shared, and the status of the executed task. |
<document_id> | TEXT | The ID of the document that will be shared. |
<email_id> | TEXT/ LIST | The email address of the user with whom the document will be shared. Note: The maximum number of email addresses that can be specified is 10. |
<role> | TEXT | The role of the user with whom the document is shared. The allowed values for this parameter are as follows:
|
<type> | TEXT | The visibility of the document. Allowed values:
|
<connection> | TEXT | The link name of the connection. Note:
|
Example 1: Share a document with one user
The following script shares the specified document with the user - shawn@zylker.com while assigning the role - co_owner.
response = zoho.writer.shareDocument("al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c", "shawn@zylker.com", "co_owner", "personal", "writer_oauth_connection");
where:
response
"al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c"
"shawn@zylker.com"
"co_owner"
"personal"
"writer_oauth_connection"
Example 2: Share a document with a list of users
The following script shares the specified document with the all the users in the list - collaborators_list while assigning the role - editor.
collaborators_list = List(); collaborators_list.add("shawn@zylker.com"); collaborators_list.add("mike.n@zylker.com"); response = zoho.writer.shareDocument("al296XXXXXXXXXXXXXXXXXXXXXXXXXXXa516c", collaborators_list, "viewer", "personal", "writer_oauth_connection");
where:
collaborators_list
"editor"
Response Format
Success Response
The success response will be returned in the following format:
{
"success": [
{
"email_id": "shawn@zylker.com",
"role": "viewer",
"user_id": "53XXXX53",
"time_ms": 1563964827313,
"shared_by": {
"email_id": "charlie.p@zylker.com",
"profile_photo": "https://contacts.zoho.com/file?t=user&ID=58XXXX70&fs=thumb",
"user_id": "58XXXX70",
"display_name": "Charlie"
},
"time": "2019-07-24T10:40:27Z",
"type": "personal",
"status": true
},
{
"email_id": "mike.n@zylker.com",
"role": "viewer",
"user_id": "53XXXX53",
"time_ms": 1563964827378,
"shared_by": {
"email_id": "charlie.p@zylker.com",
"profile_photo": "https://contacts.zoho.com/file?t=user&ID=58XXXX70&fs=thumb",
"user_id": "58XXXX70",
"display_name": "Charlie"
},
"time": "2019-07-24T10:40:27Z",
"type": "personal",
"status": true
}
],
"failure": [
]
}
Failure Response
The failure response will be returned in the following format for improper document ID:
{
"error": {
"message": "Request URL not configured properly. Please check and try again",
"documentation_url": "https://www.zoho.com/writer/help/api/v1/general-errors.html",
"response_generated_time": 1563961624177,
"request_url": "https://writer.zoho.com/api/v1/documents//collaboration",
"errorcode": "R2008"
}The failure response when you try to share a document that is not owned or co-owned by you will be returned in the following format:
{
"error": { "message": "Permission denied. You are not authorized to perform this operation.", "documentation_url": "https://www.zoho.com/writer/help/api/v1/general-errors.html", "response_generated_time": 1563961602526, "request_url": "https://writer.zoho.com/api/v1/documents/al296XXXXXXXXXXXXXXXXXXXXXXXX6964add/collaboration", "errorcode": "R5010" } }The failure response will be returned in the following format when you try to share the document with more than 10 users:
{
"error": {
"message": "You seem to have used the supported parameters multiple times.",
"documentation_url": "https://www.zoho.com/writer/help/api/v1/general-errors.html",
"response_generated_time": 1564648109086,
"request_url": "https://writer.zoho.com/api/v1/documents/al296XXXXXXXXXXXXXXXXXXXXXXXX6964add/collaboration",
"errorcode": "R2004"
}
}