0

The error:

Exception: Service invoked too many times in a short time: urlfetch. Try Utilities.sleep(1000) between calls.

the code:

  const ss = clustersSheet;
  const [header, ...data] = ss.getDataRange().getValues()
    .filter(row => row != '' ? row : null);
  var start = cachedSettings2Data[14][6];
  while(start<=ss.getLastRow()){
    const requests = data.slice(start,start+50).map(column => column[header.indexOf("Primary Keyword")])
    .map(primary_keyword => `${baseUrl}${primary_keyword}${rest_of_query}`);
  console.log(requests)
  start = start+ requests.length;
  const responses = UrlFetchApp.fetchAll(requests);
  //up to here
  const parsed_responses = responses.map(response => JSON.parse(response.getContentText()));
  console.log(parsed_responses);

The error mentions "urlfetch" being invoked too many times, but to be clear I am only using fetchAll in my code. I managed a workaround by batching my data and doing batches of 50 requests, however I would like a way to do fetchall on high numbers of requests

  • About `Exception: Service invoked too many times in a short time: urlfetch. Try Utilities.sleep(1000) between calls.`, in your showing script, it seems that this is not tested. How about this? And, in your situation, how is your script run? – Tanaike Jan 22 '23 at 23:35
  • Please avoid expressions that doesn't contribute to the question clarity. Ref. https://stackexchange.com/help/behavior. – Rubén Jan 23 '23 at 00:44
  • @Ruben your link goes nowhere – Dev_been_here_before Jan 23 '23 at 04:22
  • @Tanaike The script is run as a google sheets extension. How do you mean that error is not tested in my script? – Dev_been_here_before Jan 23 '23 at 04:25
  • Sorry The correct link is https://stackoverflow.com/help/behavior – Rubén Jan 23 '23 at 04:44
  • Thank you for replying. I have to apologize for my poor English skill. Unfortunately, I cannot understand `The script is run as a google sheets extension.`. About `How do you mean that error is not tested in my script?`, I couldn't find `Utilities.sleep(#)` in your script. So, I asked about it. I apologize for this. – Tanaike Jan 23 '23 at 05:02
  • @Tanaike thank you for your reply. You are correct I did not add Utilities.sleep(#) because I did not want to slow down the script in that way. – Dev_been_here_before Jan 24 '23 at 21:12

0 Answers0