Function Only Working Manually

Function Only Working Manually

Good evening everyone.

I have a function that creates a PDF from a Creator form. When I execute it manually it works perfectly. But when I execute it from within a On success workflow it is not working. I'll post my code below. Any ideas? 
  1. //Function
  2. void UploadPDFtoDeals(bigint SodexoSqId, string fileName, bigint dealId)
  3. {
  4. exportPDF = invokeurl
  5. [
  6. url : toPdfLink
  7. type :GET
  8. response-format:FILE
  9. ];
  10. //info exportPDF;
  11. crmResponse = zoho.crm.attachFile("Deals",dealId,exportPDF);
  12. }
Here is the On Success Workflow snippet.
  1. // Attach PDF of Form
  2. if(dealResponse.get("Status") == "success")
  3. {
  4. recordDetailsDeal = dealResponse.get("Details");
  5. dealId = recordDetailsDeal.get("id").toLong();
  6. thisapp.UploadPDFtoDeals(input.ID,dealName + " - " + dealCounter,dealId);
  7. }