2

I am getting the following error in my Sheets Add-on:

Service invoked too many times for one day: urlfetch

I'm aware of the limits here, but how can I tell if I am hitting the "URLFetch calls" of 100,000 or the "URLFetch data received" of 100mB? They are two very different issues and if I'm hitting the first one, I must be making requests unintentionally somewhere because there's no way I'm intentionally making the call 100k times a day. It is possible I'm hitting the 100mb, but the way the error is phrased makes me think I'm hitting the first, is there anyway to know for sure which one I'm hitting?

2 Answers2

1

I have run into that too. I only have 1000 rows going out to a web service. Data did not change neither in my sheet nor in the service. But at some point today most of my cells show #Error with this cause.

I feel like it's going out to re-fetch the results way too often. Is there not some caching that can be employed?


UPDATE (long time due): adding cache was exactly what was needed. So I implemented a function fetch(url) which uses a cache and that way avoids the replicate calls.

function fetch(url) {
  var cache = CacheService.getScriptCache();
  var result = cache.get(url);
  if(!result) {
    var response = UrlFetchApp.fetch(url);
    result = response.getContentText();
    cache.put(url, result, 21600);
  }
  return result;
}
Gunther Schadow
  • 1,490
  • 13
  • 22
0

You currently can not do it.

Perhaps run a counter in your script.

turtlepower
  • 708
  • 1
  • 7
  • 18