If you’ve ever searched for “Zoho WorkDrive API” online, you’d realize that there isn’t an official document yet. The closest thing to one is this unpublished API doc that Zoho might provide you when you request for support. While useful, it’s not very comprehensive and the explanations are not thorough.
We’re here to walk you through some of the actions that you may need to perform on WorkDrive that the documentation does not clearly spell out.
You will learn how to:
This is part of The Workflow Academy’s Zoho training series to help you attain rockstar Zoho admin status.
Fortunately, Zoho has made this part easy with the createFolder function. Just input the subfolder name, parent folder ID and your WorkDrive Connection name.
Note: Folder ID can be found at the end of the WorkDrive folder URL “https://workdrive.zoho.com/home/…/folders/aeci1a880e2a09bcf4641b2ef7c60e81b7b2f”
response = zoho.workdrive.createFolder("INSERT SUBFOLDER NAME", "INSERT MAIN FOLDER ID", "INSERT_WORKDRIVE_OAUTH_CONNECTION");
This script creates a new blank Zoho Writer doc and stores in the specified WorkDrive folder.
attributes = Map();
attributes.put("filename","INSERT FILE NAME");
attributes.put("folder_id","INSERT MAIN FOLDER ID");
newDoc = invokeurl
[
url :"https://zohoapis.com/writer/api/v1/documents"
type :POST
parameters:attributes
connection:"INSERT_WRITER_OAUTH_CONNECTION"
];
values_map = Map();
values_map.put("INSERT MERGE FIELD NAME","INSERT MERGE FIELD VALUE"); //Add more accordingly
output_settings = Map();
output_settings.put("doc_name","INSERT FILE NAME HERE");
output_settings.put("folder_id","INSERT FOLDER ID");
createDoc = zoho.writer.mergeAndStore("INSERT WRITER DOC TEMPLATE ID",values_map,output_settings,"INSERT_WRITER_OAUTH_CONNECTION");
info createDoc;
//Header
mp = Map();
mp.put("Accept","application/vnd.api+json");
//Parameters Map
externalLinkMap = Map();
externalLinkMap.put("resource_id","INSERT FOLDER OR WRITER DOC ID");
externalLinkMap.put("link_name","INSERT A LINK NAME");
externalLinkMap.put("request_user_data",false);
externalLinkMap.put("allow_download",true);
externalLinkMap.put("role_id","7");
attributesMap = {"attributes":externalLinkMap,"type":"links"};
dataMap = Map();
dataMap.put("data",attributesMap);
//API Call
createExternalLink = invokeurl
[
url :"https://workdrive.zoho.com/api/v1/links"
type :POST
parameters:dataMap.toString()
headers:mp
connection:"INSERT_WORKDRIVE_OAUTH_CONNECTION"
];
//Get External Share Link
shareLink = createExternalLink.get("data").get("attributes").get("link");
info shareLink;
header = Map();
header.put("Accept","application/vnd.api+json");
data = {"data":{"attributes":{"status":"1"},"type":"files"}};
markAsReady = invokeurl
[
url :"https://workdrive.zoho.com/api/v1/files/" + "INSERT_WRITER_DOC_ID"
type :PATCH
parameters:data.toString()
headers:header
connection:"INSERT_WRITER_OAUTH_CONNECTION"
];
info markAsReady;
Click here to copy the scripts. For more Zoho-wizardry, check out our GitHub page.
Book a free 30-minutes consultation with a Zoho expert or send us an email