user2494206
user2494206

Reputation: 11

UrlFetchApp.fetch Error 504

I have a google spreadsheet as an attached script. The script sends the spreadsheet to a list of specific users.

The code was working sometimes, then began to fail sporadically, now fails consistently.

The failing code is :

function GetResult(url , requestData, ReportName)
  {
    var iCount = 0;
    var successful = false;
    var result = null;

    while(!successful)
    {
      try
      {
        result = UrlFetchApp.fetch(url , requestData);
        successful = true;
        LoopCounter( ReportName + ": " +  iCount);
      }
      catch(e)
      {
        var stringgie = e;
        iCount = iCount + 1;
        LoopCounter( ReportName + ": " + iCount);
        successful = false;
      }
    }
    return result;
  }

the line that fails is

result = UrlFetchApp.fetch(url, requestData);

I suspect that its maxed out the "Free" portion of my google account, Now if I wanted to pay for additional processing I have no idea how to do so.

At the same time looking to the quota, I don't know why I'd be exceeding the applications limit, I can't see the application making that many requests !!

The error description that comes back is less than useful.

Upvotes: 1

Views: 741

Answers (1)

Rafael De Alemar Vidal
Rafael De Alemar Vidal

Reputation: 173

Can you post what's the error code or error description? You could try to mute exceptions using on your requestData parameter {muteHttpExceptions: true}

I have a Google Apps Business account in Google, still I've been having the same problem as yours. The error 503 happens randomly, and lately is been happening quite often.

I suspect UrlFetchApp is returning this error when the Spreadsheet or Google Server is slow and take too long to give the return Header. In our case, the UrlFetchApp problem happens in those 3 cases listed bellow:

  • when we try to retrieve data from heavy loaded Spreadsheet
  • when there is simultaneous access to it, or
  • when Google Servers are slow (which is quite frequent nowadays)

In another words, UrlFetchApp is timing out!

Upvotes: 0

Related Questions