Value is empty and 'isEmpty' function cannot be applied

Value is empty and 'isEmpty' function cannot be applied

Hello,

I am having a very strange error in my custom  function with Deluge. It is a function that creates. invoices automatically every Friday if the sales order is shipped. I added a verification to know if the customer has credit notes actives. If the costumer has some credits, the invoice is not created. 
The thing is I am receiving the error you see in the title "Check and update the code in line 76 as there is a Exception : Value is empty and 'isEmpty' function cannot be applied"

  1. urlcredit = "https://books.zoho.eu/api/v3/creditnotes?organization_id=" + organizationID + "&customer_id=" + customerID + "&status=open";
  2. credit_note = invokeurl
  3. [
  4. url :urlcredit
  5. type :GET
  6. connection:"v2_books_conpas"
  7. ];
  8. comp_tienecredito = credit_note.get("creditnotes");
  9. if(comp_tienecredito.isEmpty() == false)
  10. {
  11. tieneCredito = true;
  12. numeroCreditos = numeroCreditos + 1;
  13. }