0

I've been using Google Apps Script to fetch orders for my school's website for years without issue. All of a sudden—starting on April 27, 2021—all of my API calls are failing with the error "Exception: Timeout", despite them only processing for about 4 seconds.

Did something change on Google's end that could cause these errors?

I can successfully fetch some URLs, but none that use my school website's domain...including the homepage itself (let alone any APIs on it).

In Postman, I can still successfully fetch all of the APIs (and the school homepage, of course).

I'm at a loss.

2 Answers2

0

AFAIK nothing has changed

At least there have been no announcements or anything like that.

Searching the Issue Tracker, there are no new UrlFetchApp issues that have been posted. If it was a widespread error then there would usually be an issue with a load of "stars" indicating a lot of people affected by it. It seems to be working for me, though if you have reproduction instructions you might consider filling out this template and filing a report:

https://issuetracker.google.com/issues/new?component=191640&template=823905

UrlFetchApp has been known to sometimes have outages or variable completion times, hence the popular feature request:

Extend or allow configurable timeout for UrlFetchApp.fetch

Also a quick search reveals many issues:

https://issuetracker.google.com/issues?q=urlfetchapp%20timeout

Most of which are relatively short lived and not reliably reproducible, which makes it problematic for Google to diagnose since they usually can't reproduce it, and as such, cannot locate the source of the error.

The issue may be on the school side (unlikely from the sound of it), that they have decided to block certain user-agents, is there a way for you to check that?

Check if the issue persists and is reliably failing in the same way every time, if you can provide a way to reproduce the error reliably then it may be worth filing the issue as mentioned above. Be sure to mention your stats too, % of fails, exact times, and what it is exactly that you are trying to do.

On that note, if you can elaborate on the details of what you are trying to do, then maybe some workarounds can be offered.

iansedano
  • 4,252
  • 2
  • 9
  • 19
0

This Stack Overflow post didn't address my situation exactly, but it did lead me to calling the API from a function in the sheet itself, which led to me checking the console in the browser, which revealed that the actual API error was NOT a timeout (despite what GAS was saying) and was in fact a 401!

{"code":"woocommerce_rest_cannot_view","message":"Sorry, you cannot list resources.","data":{"status":401}}

This didn't make a ton of sense, though, since my authorization had been working for years, and it still worked in Postman. A bit of googling, however, led me to this StackOverflow response from Tony Petruzzi, which miraculously resolved my issue! I have no idea why this would all-of-a-sudden be needed, though.

Needed for WooCommerce API

For future Googlers... I needed to added this to my .htaccess

  RewriteRule ^index.php$ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]