Deluge: How to get the application/octet-stream response using the 'invokeUrl' method?

Deluge: How to get the application/octet-stream response using the 'invokeUrl' method?

I'm in the middle of setting up a 'scheduled email notifications' Flow, but I am unsure if this is the best path to do it. So alternate title for this post is "What's the best setup for emailing an inventory feed to your customers."

The setup is simple, I added a scheduled trigger and connected it to a function that 1. requests an excel file from SharePoint REST API, 2. fetches all customers with "Inventory Feed" field selected, and 3. sends an email with the file from SharePoint attached.

Here's a snippet

  1. void send_inventory_feed_to_email()
  2. {
  3. // 1. requests an excel file from SharePoint Rest API
  4. token = get_sharepoint_token(); 
  5. url = "https://domain.sharepoint.com/sites/Team/_api/Web/GetFolderByServerRelativePath(decodedurl='/sites/SomeFolder')/Files('Inventory.xlsx')/$value";

  6. // main issue - 'excel_file_from_sharepoint' returns "1667937294042.octet-stream" - a string instead an actual octet-stream content
  7. excel_file_from_sharepoint = invokeurl
  8. [
  9. url :url
  10. type :GET
  11. headers:{"Authorization":"Bearer ".concat(token),"Content-Type":"application/octet-stream","Accept":"application/octet-stream"}
  12. ];
  13.      
  14.  // 2. fetches all customers with "Inventory Feed" field selected
  15. for each  subscriber in get_inventory_feed_subscribers()
  16. {
  17. // I'm not sure if this is the right way of using the Upload attachment API, so correct me if I'm wrong
  18. attachment = invokeurl
  19. [
  20. url :"https://mail.zoho.com/api/accounts/xxxxxxxxxxxxxxxxxxxx/messages/attachments"
  21. type :POST
  22. parameters:{"fileName":"Inventory Feed.xlsx","file":excel_file_from_sharepoint}
  23. content-type:"multipart/form-data"
  24. ];
  25. attachment = attachment.get("data").get(0);
  26.  //3. sends an email with the file from SharePoint attached
  27. email = invokeurl
  28. [
  29. url :"https://mail.zoho.com/api/accounts/xxxxxxxxxxxxxxxxxxxx/messages/messages"
  30. type :POST
  31. parameters:{"attachments":{"storeName":attachment.get("storeName"),"attachmentPath":attachment.get("attachmentPath"),"attachmentName":attachment.get("attachmentName")}}
  32. ];
  33. }
  34. }
I'm getting a string instead an application/octet-stream content.

Zoho Flow:
Postman: