Unable to create a download link for an uploaded Workdrive File

Unable to create a download link for an uploaded Workdrive File

Hello,

I have some custom logic that is working fine to load image files into a Workdrive folder.

I'm not having much success however in being able to then set the file as downloadable and retrieving the download link from my custom logic.

My code for this part is:

  1. workdriveFile = Map();
  2. workdriveFile = zoho.workdrive.uploadFile(file_data,workdrive_folder_id,file_name,false,"zoho_workdrive");
  3. file = workdriveFile.get("data").get(0).get("attributes").get("Permalink");
  4. info "Workdrive File:";
  5. info workdriveFile.toString();
  6. resourceId = file.remove("https://workdrive.zoho.com/file/");
  7. HeaderMap = Map();
  8. HeaderMap.put("Accept",mime_type);
  9. ExternalLinkMap = Map();
  10. ExternalLinkMap.put("resource_id",resourceId);
  11. ExternalLinkMap.put("link_name",resourceId);
  12. ExternalLinkMap.put("request_user_data","false");
  13. ExternalLinkMap.put("allow_download","true");
  14. ExternalLinkMap.put("role_id","6");
  15. AttributesMap = {"attributes":ExternalLinkMap,"type":"links"};
  16. DataMap = Map();
  17. DataMap.put("data",AttributesMap);
  18. info "Parameters:";
  19. info DataMap.toString();
  20. CreateExternalLink = Map();
  21. CreateExternalLink = invokeurl
  22. [
  23. url :"https://workdrive.zoho.com/api/v1/links"
  24. type :POST
  25. parameters:DataMap.toString()
  26. connection:"zoho_workdrive"
  27. ];
  28. //ShareLink = CreateExternalLink.get("data").get("attributes").get("link");
  29. info CreateExternalLink.toString();

Below is the result from Flow:
  1. {
  2. "info_logs": [
  3. "Workdrive File:",
  4. {
  5. "data": [
  6. {
  7. "attributes": {
  8. "Permalink": "https://workdrive.zoho.com/file/p56860ee52ce9850a4cd79d2fc39357588b48",
  9. "File INFO": {
  10. "ORG_ID": "94pew6826015fadde439f805899f17d2ff26e",
  11. "RESOURCE_ID": "p56860ee52ce9850a4cd79d2fc39357588b48",
  12. "LIBRARY_ID": "nhi958034f1f94f5f4c3b90e2b588c99b56b8",
  13. "PARENT_MODEL_ID": "nhi955f40a4daefae4f3fbd18e362fd7ecf86",
  14. "PARENT_ID": "nhi955f40a4daefae4f3fbd18e362fd7ecf86",
  15. "RESOURCE_TYPE": 2501,
  16. "WMS_SENT_TIME": 1632390988265,
  17. "TAB_ID": -1,
  18. "OWNER": 673649126,
  19. "RESOURCE_GROUP": "FILE",
  20. "PARENT_MODEL_NAME": "file",
  21. "size": 68242,
  22. "OPERATION": "UPLOAD",
  23. "EVENT_ID": -1,
  24. "AUDIT_INFO": {
  25. "resource": {
  26. "owner": 673649126,
  27. "created_time": 1632390988204,
  28. "creator": 653631583,
  29. "service_type": 4,
  30. "extension": "jpeg",
  31. "resource_type": 2501,
  32. "name": "123_1 (19).jpeg"
  33. },
  34. "parentInfo": {
  35. "parentName": "MMS",
  36. "parentId": "nhi955f40a4daefae4f3fbd18e362fd7ecf86",
  37. "parentType": 1001
  38. },
  39. "libraryInfo": {
  40. "libraryName": "Cliq",
  41. "libraryId": "nhi958034f1f94f5f4c3b90e2b588c99b56b8",
  42. "libraryType": 14
  43. },
  44. "statusCode": "D201"
  45. },
  46. "ZUID": 653631583,
  47. "TEAM_ID": "94pew6826015fadde439f805899f17d2ff26e"
  48. },
  49. "parent_id": "nhi955f40a4daefae4f3fbd18e362fd7ecf86",
  50. "FileName": "123_1 (19).jpeg",
  51. "resource_id": "p56860ee52ce9850a4cd79d2fc39357588b48"
  52. },
  53. "type": "files"
  54. }
  55. ]
  56. },
  57. "Parameters:",
  58. {
  59. "data": {
  60. "attributes": {
  61. "resource_id": "p56860ee52ce9850a4cd79d2fc39357588b48",
  62. "link_name": "p56860ee52ce9850a4cd79d2fc39357588b48",
  63. "request_user_data": false,
  64. "allow_download": true,
  65. "role_id": 6
  66. },
  67. "type": "links"
  68. }
  69. },
  70. ""
  71. ],
  72. "extractMMS_19": ""
  73. }
The info sections are arranged in three blocks.  The first block at line 3 is the result from the initial file upload, which is working fine.

The second block at line 57 is the parameters as they've been defined for creating the shareable link.  The response at line 70 is null.

Is there something i'm not setting up correctly?

Thanks,
Bryan