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.
- userList = List();
- currentMonth = zoho.currentdate;
- firstDay = currentMonth.eomonth(0);
- lastDay = currentMonth.eomonth(-1).addDay(1);
- headerUser = Map();
- headerUser.put("X-com-zoho-expense-organizationid","643169496");
- usersresponse = invokeurl
- [
- url :"https://www.zohoapis.com/expense/v1/users"
- type :GET
- headers:headerUser
- connection:"adminexpense"
- ];
- users = usersresponse.get("users");
- for each person in users
- {
- userID = person.get("user_id");
- userList.add(userID);
- }
- for each ID in userList
- {
- params = Map();
- params.put("user_id",ID);
- params.put("date_start",firstDay);
- params.put("date_end",lastDay);
- headers_data = Map();
- headers_data.put("X-com-zoho-expense-organizationid","643169496");
- response = invokeurl
- [
- url :"https://www.zohoapis.com/expense/v1/reports/expensedetails"
- type :GET
- parameters:params
- headers:headers_data
- connection:"adminexpense"
- ];
- if(response.get("message") == "Please check the date range")
- {
- continue;
- }
- info response;
- }