I keep getting a max number of requests error in my function

I keep getting a max number of requests error in my function

There was a change in how report automation is made and it caused us having to create a custom function in zoho expense. I'm trying to grab all expenses of the month from each user and create a report. However, I'm getting too many API Calls error. How am i able to fix that? try used a try-catch but I was still getting the same error. This is my current code, there are over 100 users.

  1. userList = List();
  2. currentMonth = zoho.currentdate;
  3. firstDay = currentMonth.eomonth(0);
  4. lastDay = currentMonth.eomonth(-1).addDay(1);
  5. headerUser = Map();
  6. headerUser.put("X-com-zoho-expense-organizationid","643169496");
  7. usersresponse = invokeurl
  8. [
  9. url :"https://www.zohoapis.com/expense/v1/users"
  10. type :GET
  11. headers:headerUser
  12. connection:"adminexpense"
  13. ];
  14. users = usersresponse.get("users");
  15. for each  person in users
  16. {
  17. userID = person.get("user_id");
  18. userList.add(userID);
  19. }
  20. for each  ID in userList
  21. {
  22. params = Map();
  23. params.put("user_id",ID);
  24. params.put("date_start",firstDay);
  25. params.put("date_end",lastDay);
  26. headers_data = Map();
  27. headers_data.put("X-com-zoho-expense-organizationid","643169496");
  28. response = invokeurl
  29. [
  30. url :"https://www.zohoapis.com/expense/v1/reports/expensedetails"
  31. type :GET
  32. parameters:params
  33. headers:headers_data
  34. connection:"adminexpense"
  35. ];
  36. if(response.get("message") == "Please check the date range")
  37. {
  38. continue;
  39. }
  40. info response;
  41. }

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now