For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Workdrive: Getting Team Folder ID

Zoho Workdrive: Getting Team Folder ID

What?
This is an article to document how to get your team folder ID, retrieve information about it, and upload to it via the API.

Why?
The documentation is there but making sense of it, is somewhat difficult, at least for me.

How?
So when I was trying this, I would get either "URL rule not configured" or an unhelpful blank response.

Getting the folder ID
This applies to if you click on "My Folders" and then checking the URL
copyraw
https://workdrive.zoho.com/home/{dunno_id}/privatespace/folders/{folder_id}
  1.  https://workdrive.zoho.com/home/{dunno_id}/privatespace/folders/{folder_id} 

Getting the teamfolder ID:
Access the folder in workdrive and check the URL:
copyraw
https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{team_folder_id}/folders/files
  1.  https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{team_folder_id}/folders/files 
or
copyraw
https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{team_folder_id}/folders/{team_subfolder_id}
  1.  https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{team_folder_id}/folders/{team_subfolder_id} 

Getting the team folder information
Use the team_folder_ID or if it is a subfolder, then use the team_subfolder_id Ensure the scope for your connection includes WorkDrive.teamfolders.READ and note that header has to be added otherwise you get a blank response:
copyraw
m_Header = Map();
m_Header.put("Accept","application/vnd.api+json");
v_Endpoint = "https://www.zohoapis.com/workdrive/api/v1/teamfolders/{team_folder_id}/folders";
r_TeamFolderInfo = invokeurl
[
	url :v_Endpoint
	type :GET
	headers:m_Header
	connection:"my_workdrive_connection"
];
info r_TeamFolderInfo;
  1.  m_Header = Map()
  2.  m_Header.put("Accept","application/vnd.api+json")
  3.  v_Endpoint = "https://www.zohoapis.com/workdrive/api/v1/teamfolders/{team_folder_id}/folders"
  4.  r_TeamFolderInfo = invokeurl 
  5.  [ 
  6.      url :v_Endpoint 
  7.      type :GET 
  8.      headers:m_Header 
  9.      connection:"my_workdrive_connection" 
  10.  ]
  11.  info r_TeamFolderInfo; 

The one to rule them all
copyraw
// ======================
// get folder information
// https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{team_folder_id}/folders/files
m_Header = Map();
m_Header.put("Accept","application/vnd.api+json");
v_Endpoint = "https://www.zohoapis.com/workdrive/api/v1/teamfolders/{team_folder_id}/folders";
r_TeamFolderInfo = invokeurl
[
	url :v_Endpoint
	type :GET
	headers:m_Header
	connection:"my_workdrive_connection"
];
//info r_TeamFolderInfo;
//
// ======================
// get list of subfolders by name (creates a timestamped duplicate if exists so need to check if it exists first)
// https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{parent_id}/folders/files
m_SubfolderNames = Map();
r_Subfolders = invokeurl
[
	url :"https://www.zohoapis.com/workdrive/api/v1/teamfolders/{parent_id}/folders?page%5Blimit%5D=50&page%5Boffset%5D=0"
	type :GET
	headers:m_Header
	connection:"my_workdrive_connection"
];
if(!isNull(r_Subfolders.get("data")))
{
	for each  m_Subfolder in r_Subfolders.get("data")
	{
		if(!isNull(m_Subfolder.get("attributes")))
		{
			m_SubfolderNames.put(m_Subfolder.get("attributes").get("name"), m_Subfolder.get("id"));
		}
	}
}
// info r_Subfolders;
// info m_SubfolderNames;
//
// ======================
// create sub folder
v_ParentFolderID = "{parent_id}";
v_WorkdriveFolderID = "";
v_WorkingFolderName = zoho.currentdate.toString("yyyy");
if(!m_SubfolderNames.keys().contains(v_WorkingFolderName))
{
	m_Attr = Map();
	m_Attr.put("name", v_WorkingFolderName);
	m_Attr.put("parent_id", v_ParentFolderID);
	//
	m_Params = Map();
	m_Params.put("attributes", m_Attr);
	m_Params.put("type", "files");
	//
	m_Data = Map();
	m_Data.put("data", m_Params);
	r_WorkdriveFolder = invokeurl
	[
		url :"https://www.zohoapis.com/workdrive/api/v1/files"
		type :POST
		parameters:m_Data.toString()
		headers:m_Header
		connection:"my_workdrive_connection"
	];
	if(!isNull(r_WorkdriveFolder.get("id")))
	{
		v_WorkdriveFolderID = r_WorkdriveFolder.get("id");
		//
		// ======================
		// share folder to members woh can access it (read-only)
		//
		// list of recipients
		l_WorkdriveRecipients = {"This email address is being protected from spambots. You need JavaScript enabled to view it.","This email address is being protected from spambots. You need JavaScript enabled to view it."};
		//
	        for each v_RecipientEmail in l_WorkdriveRecipients
                {
			m_Header = Map();
			m_Header.put("Accept","application/vnd.api+json");
			m_Attributes = Map();
			m_Attributes.put("resource_id",v_WorkdriveFolderID);
			m_Attributes.put("shared_type","workspace");
			m_Attributes.put("email_id",v_RecipientEmail);
		// role id 34 is view only on the file (see below for further permissions)
			m_Attributes.put("role_id",34);
			m_Data = Map();
			m_Data.put("attributes", m_Attributes);
			m_Data.put("type", "members");
			m_Params = Map();
			m_Params.put("data",m_Data);
			//
			r_WorkdriveMembers = invokeurl
			[
				url :"https://www.zohoapis.eu/workdrive/api/v1/members"
				type :POST
				parameters:m_Params.toString()
				headers:m_Header
				connection:"my_workdrive_connection"
			];
			info "Workdrive Member Added: " + v_RecipientEmail;		
                }
	}
	info r_WorkdriveFolder;
}
else 
{
	v_WorkdriveFolderID = m_SubfolderNames.get(v_WorkingFolderName);
}
// ======================
// upload the file to this folder
if(v_WorkdriveFolderID != "")
{
	v_PermaLink = "";
	//
	// generate a test CSV
	v_NewLineChar = hextoText("0A");
	l_Csv_File = {"Header1,Header2","Row1_Data1,Row1_Data2","Row2_Data1,Row2_Data2"};
	v_UploadFilename = " Test Upload " + zoho.currenttime.toString("yyyy-MM-dd-HH-mm") + ".csv";
	f_UploadCsvFile = l_Csv_File.toString(v_NewLineChar).toFile(v_UploadFilename);
	//
	// upload the file
	r_UploadResponse = zoho.workdrive.uploadFile(f_UploadCsvFile,v_WorkdriveFolderID,v_UploadFilename,FALSE,"my_workdrive_connection");
	if(!isNull(r_UploadResponse.get("data")))
	{
		// looping but only have 1 upload so getting permalink for this upload
		for each m_ThisData in r_UploadResponse.get("data")
		{
			if(!isNull(m_ThisData.get("attributes")))
			{
				if(!isNull(m_ThisData.get("attributes").get("Permalink")))
				{
					v_PermaLink = m_ThisData.get("attributes").get("Permalink");
				}
			}
		}
	}		
}
// ====================================
// send an email with the permalink
v_Subject = "Data for Export w/c: " + zoho.currentdate.toStartOfWeek().toString("yyyy-MM-dd");
v_Message = "To he who shall not be named,<br /><br /><b>Re: " + v_Subject + "</b><br /><br />Please find attached the CSV export file containing the Data.  ";
// 
if(!isBlank(v_PermaLink))
{
	v_Message = v_Message + "<br/>The export file has been uploaded to the workdrive.  The direct link to the file is <a href=\"" + v_PermaLink + "\">" + v_UploadFilename + "</a>. <br/>";
}
// 
v_Message = v_Message + "This file is ready for importing into the system.<br /><br />Kind Regards,<br /><br />The Development Team.";
//
// list of recipients
l_RecipientsEmails = {"This email address is being protected from spambots. You need JavaScript enabled to view it.","This email address is being protected from spambots. You need JavaScript enabled to view it."};
//
// send email
sendmail
[
	from :zoho.adminuserid
	to :l_RecipientsEmails
	subject :v_Subject
	message :v_Message
]
  1.  // ====================== 
  2.  // get folder information 
  3.  // https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{team_folder_id}/folders/files 
  4.  m_Header = Map()
  5.  m_Header.put("Accept","application/vnd.api+json")
  6.  v_Endpoint = "https://www.zohoapis.com/workdrive/api/v1/teamfolders/{team_folder_id}/folders"
  7.  r_TeamFolderInfo = invokeurl 
  8.  [ 
  9.      url :v_Endpoint 
  10.      type :GET 
  11.      headers:m_Header 
  12.      connection:"my_workdrive_connection" 
  13.  ]
  14.  //info r_TeamFolderInfo; 
  15.  // 
  16.  // ====================== 
  17.  // get list of subfolders by name (creates a timestamped duplicate if exists so need to check if it exists first) 
  18.  // https://workdrive.zoho.com/home/{dunno_id}/teams/{dunno_id}/ws/{parent_id}/folders/files 
  19.  m_SubfolderNames = Map()
  20.  r_Subfolders = invokeurl 
  21.  [ 
  22.      url :"https://www.zohoapis.com/workdrive/api/v1/teamfolders/{parent_id}/folders?page%5Blimit%5D=50&page%5Boffset%5D=0" 
  23.      type :GET 
  24.      headers:m_Header 
  25.      connection:"my_workdrive_connection" 
  26.  ]
  27.  if(!isNull(r_Subfolders.get("data"))) 
  28.  { 
  29.      for each  m_Subfolder in r_Subfolders.get("data") 
  30.      { 
  31.          if(!isNull(m_Subfolder.get("attributes"))) 
  32.          { 
  33.              m_SubfolderNames.put(m_Subfolder.get("attributes").get("name"), m_Subfolder.get("id"))
  34.          } 
  35.      } 
  36.  } 
  37.  // info r_Subfolders; 
  38.  // info m_SubfolderNames; 
  39.  // 
  40.  // ====================== 
  41.  // create sub folder 
  42.  v_ParentFolderID = "{parent_id}"
  43.  v_WorkdriveFolderID = ""
  44.  v_WorkingFolderName = zoho.currentdate.toString("yyyy")
  45.  if(!m_SubfolderNames.keys().contains(v_WorkingFolderName)) 
  46.  { 
  47.      m_Attr = Map()
  48.      m_Attr.put("name", v_WorkingFolderName)
  49.      m_Attr.put("parent_id", v_ParentFolderID)
  50.      // 
  51.      m_Params = Map()
  52.      m_Params.put("attributes", m_Attr)
  53.      m_Params.put("type", "files")
  54.      // 
  55.      m_Data = Map()
  56.      m_Data.put("data", m_Params)
  57.      r_WorkdriveFolder = invokeurl 
  58.      [ 
  59.          url :"https://www.zohoapis.com/workdrive/api/v1/files" 
  60.          type :POST 
  61.          parameters:m_Data.toString() 
  62.          headers:m_Header 
  63.          connection:"my_workdrive_connection" 
  64.      ]
  65.      if(!isNull(r_WorkdriveFolder.get("id"))) 
  66.      { 
  67.          v_WorkdriveFolderID = r_WorkdriveFolder.get("id")
  68.          // 
  69.          // ====================== 
  70.          // share folder to members woh can access it (read-only) 
  71.          // 
  72.          // list of recipients 
  73.          l_WorkdriveRecipients = {"This email address is being protected from spambots. You need JavaScript enabled to view it.","This email address is being protected from spambots. You need JavaScript enabled to view it."}
  74.          // 
  75.              for each v_RecipientEmail in l_WorkdriveRecipients 
  76.                  { 
  77.              m_Header = Map()
  78.              m_Header.put("Accept","application/vnd.api+json")
  79.              m_Attributes = Map()
  80.              m_Attributes.put("resource_id",v_WorkdriveFolderID)
  81.              m_Attributes.put("shared_type","workspace")
  82.              m_Attributes.put("email_id",v_RecipientEmail)
  83.          // role id 34 is view only on the file (see below for further permissions) 
  84.              m_Attributes.put("role_id",34)
  85.              m_Data = Map()
  86.              m_Data.put("attributes", m_Attributes)
  87.              m_Data.put("type", "members")
  88.              m_Params = Map()
  89.              m_Params.put("data",m_Data)
  90.              // 
  91.              r_WorkdriveMembers = invokeurl 
  92.              [ 
  93.                  url :"https://www.zohoapis.eu/workdrive/api/v1/members" 
  94.                  type :POST 
  95.                  parameters:m_Params.toString() 
  96.                  headers:m_Header 
  97.                  connection:"my_workdrive_connection" 
  98.              ]
  99.              info "Workdrive Member Added: " + v_RecipientEmail; 
  100.                  } 
  101.      } 
  102.      info r_WorkdriveFolder; 
  103.  } 
  104.  else 
  105.  { 
  106.      v_WorkdriveFolderID = m_SubfolderNames.get(v_WorkingFolderName)
  107.  } 
  108.  // ====================== 
  109.  // upload the file to this folder 
  110.  if(v_WorkdriveFolderID != "") 
  111.  { 
  112.      v_PermaLink = ""
  113.      // 
  114.      // generate a test CSV 
  115.      v_NewLineChar = hextoText("0A")
  116.      l_Csv_File = {"Header1,Header2","Row1_Data1,Row1_Data2","Row2_Data1,Row2_Data2"}
  117.      v_UploadFilename = " Test Upload " + zoho.currenttime.toString("yyyy-MM-dd-HH-mm") + ".csv"
  118.      f_UploadCsvFile = l_Csv_File.toString(v_NewLineChar).toFile(v_UploadFilename)
  119.      // 
  120.      // upload the file 
  121.      r_UploadResponse = zoho.workdrive.uploadFile(f_UploadCsvFile,v_WorkdriveFolderID,v_UploadFilename,FALSE,"my_workdrive_connection")
  122.      if(!isNull(r_UploadResponse.get("data"))) 
  123.      { 
  124.          // looping but only have 1 upload so getting permalink for this upload 
  125.          for each m_ThisData in r_UploadResponse.get("data") 
  126.          { 
  127.              if(!isNull(m_ThisData.get("attributes"))) 
  128.              { 
  129.                  if(!isNull(m_ThisData.get("attributes").get("Permalink"))) 
  130.                  { 
  131.                      v_PermaLink = m_ThisData.get("attributes").get("Permalink")
  132.                  } 
  133.              } 
  134.          } 
  135.      } 
  136.  } 
  137.  // ==================================== 
  138.  // send an email with the permalink 
  139.  v_Subject = "Data for Export w/c: " + zoho.currentdate.toStartOfWeek().toString("yyyy-MM-dd")
  140.  v_Message = "To he who shall not be named,<br /><br /><b>Re: " + v_Subject + "</b><br /><br />Please find attached the CSV export file containing the Data.  "
  141.  // 
  142.  if(!isBlank(v_PermaLink)) 
  143.  { 
  144.      v_Message = v_Message + "<br/>The export file has been uploaded to the workdrive.  The direct link to the file is <a href=\"" + v_PermaLink + "\">" + v_UploadFilename + "</a><br/>"
  145.  } 
  146.  // 
  147.  v_Message = v_Message + "This file is ready for importing into the system.<br /><br />Kind Regards,<br /><br />The Development Team."
  148.  // 
  149.  // list of recipients 
  150.  l_RecipientsEmails = {"This email address is being protected from spambots. You need JavaScript enabled to view it.","This email address is being protected from spambots. You need JavaScript enabled to view it."}
  151.  // 
  152.  // send email 
  153.  sendmail 
  154.  [ 
  155.      from :zoho.adminuserid 
  156.      to :l_RecipientsEmails 
  157.      subject :v_Subject 
  158.      message :v_Message 
  159.  ] 


Additional Note(s):
copyraw
Allowed role IDs for files:
34 - View
5 - Edit
4 - Share
6 - View and comment
33 - View and fill

Allowed role IDs for folders:
6 - View
5 - Edit
3 - Organize
7 - Upload
  1.  Allowed role IDs for files: 
  2.  34 - View 
  3.  5 - Edit 
  4.  4 - Share 
  5.  6 - View and comment 
  6.  33 - View and fill 
  7.   
  8.  Allowed role IDs for folders: 
  9.  6 - View 
  10.  5 - Edit 
  11.  3 - Organize 
  12.  7 - Upload 


Error(s) Encountered:
When updating members to a workdrive, I was getting errors such as
  • 2945 Invalid JSON
  • 2945 Invalid JSON
copyraw
for each v_RecipientEmail in l_WorkdriveRecipients
        {
			m_Header = Map();
			m_Header.put("Accept","application/vnd.api+json");
			m_Attributes = Map();
			m_Attributes.put("resource_id",v_WorkdriveFolderID);
			m_Attributes.put("shared_type","workspace");
			m_Attributes.put("email_id",v_RecipientEmail);
			m_Attributes.put("role_id",34);
			m_Data = Map();
			m_Data.put("attributes", m_Attributes);
			m_Data.put("type", "members");
			m_Params = Map();
			m_Params.put("data",m_Data);
			//
			r_WorkdriveMembers = invokeurl
			[
				url :"https://www.zohoapis.eu/workdrive/api/v1/members"
				type :POST
				parameters:m_Params.toString()
				headers:m_Header
				connection:"ab_workdrive"
			];
			info "Workdrive Member Added: " + v_RecipientEmail;		
        }
  1.  for each v_RecipientEmail in l_WorkdriveRecipients 
  2.          { 
  3.              m_Header = Map()
  4.              m_Header.put("Accept","application/vnd.api+json")
  5.              m_Attributes = Map()
  6.              m_Attributes.put("resource_id",v_WorkdriveFolderID)
  7.              m_Attributes.put("shared_type","workspace")
  8.              m_Attributes.put("email_id",v_RecipientEmail)
  9.              m_Attributes.put("role_id",34)
  10.              m_Data = Map()
  11.              m_Data.put("attributes", m_Attributes)
  12.              m_Data.put("type", "members")
  13.              m_Params = Map()
  14.              m_Params.put("data",m_Data)
  15.              // 
  16.              r_WorkdriveMembers = invokeurl 
  17.              [ 
  18.                  url :"https://www.zohoapis.eu/workdrive/api/v1/members" 
  19.                  type :POST 
  20.                  parameters:m_Params.toString() 
  21.                  headers:m_Header 
  22.                  connection:"ab_workdrive" 
  23.              ]
  24.              info "Workdrive Member Added: " + v_RecipientEmail; 
  25.          } 


Source(s):

Category: Zoho Workdrive :: Article: 411

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com