Issue with attaching files to a task through the API

Issue with attaching files to a task through the API

Hello! 

I've implemented a function that creates a task for every new bill that is created but I haven't been able to attach to the task the files which are attached to the bill. I have encountered multiple errors but the most common one is error 33003: file not found

Here's the code snippet for my last attempt.

  1. headers_data.put("Authorization","Zoho-oauthtoken 1000.xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxx");
  2. bill_documents = invokeurl
  3. [
  4. url :"https://www.zohoapis.com/books/v3/bills/" + bill.get("bill_id") + "/attachment?organization_id=XXXXXXXX"
  5. type :GET
  6. headers:headers_data
  7. connection:conn
  8. ];
  9. if(bill_documents == null)
  10. {
  11. return;
  12. }
  13. bill_documents.setParamName("attachment");
  14. params = {"organization_id":"XXXXXXXX"};
  15. params = params.toString();
  16. res = invokeurl
  17. [
  18. url :"https://www.zohoapis.com/books/v3/tasks/" + task_id + "/attachment"
  19. type :POST
  20. parameters:params
  21. headers:headers_data
  22. files:bill_documents
  23. connection:conn
  24. ];
Can you please help me understand how my code is incorrect? The API documentation hasn't been helpful in this case.

Thanks in advance,
Luca