Zoho Desk Attachments to Zoho WorkDrive
Hi,
I have a requirement to upload attachments to WorkDrive when threads are created in Desk tickets. I have a custom function correctly identifying the attachment URLs (which I am able to open in a browser) and am trying to use these URLs to upload to WorkDrive. I am successfully connecting to the API but get a response:
- {"id":"F000","title":"LESS_THAN_MIN_OCCURANCE"}
Here is my code snippet:
- fileName = attachment.get("name");
- fileUrl = attachment.get("href") + "?orgId=" + ORGID;
- stringURL = "https://www.zohoapis.com/workdrive/api/v1/upload";
- uploadMap = Map();
- uploadMap.put("parent_id","<FOLDER ID IS HERE>");
- uploadMap.put("content",fileUrl);
- uploadMap.put("filename",fileName);
- attributesMap = Map();
- attributesMap.put("attributes",uploadMap);
- attributesMap.put("type","files");
- dataMap = Map();
- dataMap.put("data",attributesMap);
- parameters = dataMap.toString();
- info parameters;
- mp = Map();
- mp.put("Accept","application/vnd.api+json");
-
- response = invokeurl
- [
- url : stringURL
- type : POST
- parameters:parameters
- headers: mp
- connection: "zworkdrive"
- ];
- info response;
Any idea what I am doing wrong or even if this is possible? Does the file need to be local or can it be via a URL as per my requirement?
Thanks!