Unable to Upload files to ZFS in Zoho CRM API

Unable to Upload files to ZFS in Zoho CRM API

I wanted to fetch an image from an external website, and then upload it to Zoho File System so that I can attach it to an image upload field. Based from the documentation in https://www.zoho.com/crm/developer/docs/api/v3/upload-files-to-zfs.html, a sample code for uploading to Zoho File System would be:
  1. fileVariable = invokeurl
  2. [
  3.     url: "https://file-examples-com.github.io/uploads/2017/10/file-sample_150kB.pdf"
  4.    type: GET
  5. ];
  6. fileVariable.setParamName("file");
  7. response = invokeurl
  8. [
  9.     url :"https://www.zohoapis.com/crm/v3/files"
  10.     type :POST
  11.     files: fileVariable
  12.     connection:"crm_oauth_connection"
  13. ];
  14. info response;
I tried implementing in in my code. Here is what I came up with:
  1. imageUrl = https://www.sampleurl.com/sampleimage.jpg
  2. // Fetcth the image
  3. downloadResponse = invokeurl
  4. [
  5.     url :imageUrl
  6.     type :GET
  7. ];
  8. downloadResponse.setParamName("file");
  9. response = invokeurl
  10. [
  11.     url: "https://www.zohoapis.com/crm/v3/files"
  12.     type: POST
  13.     files: downloadResponse
  14.     connection:"internal_crm"
  15. ];
  16. info response;
However, when I try to run the code, the console shows "Error at line : 13, Error due to - '{0}'". Can anyone help me with this error?