Hello,
When using the UrlFetchApp function in Google App Scripts for any URLs under the V1 or V2 API (i.e. "https://api.guildwars2.com/v2" or "https://api.guildwars2.com/v1"), I get the error code 429 ("too many requests").
Does anyone have any ideas what the problem could be?
My troubleshooting:
- This fails also if I use my phone to run the script, so it is not an extension or anti-virus problem.
- However, the fetch works if I use a VPN or if I fetch the url "https://api.guildwars2.com," or if I use another website's trading post data such as "http://api.gw2tp.com/1/bulk/items.json".
- When I return the Http response headers for "https://api.guildwars2.com/v2", I get "x-rate-limit-limit': '600' " in the headers, but when I do the same for "https://api.guildwars2.com", I do not.
- I can access the URL in my browser perfectly fine.
- I used the script to fetch my personal server, which I checked the traffic of, and I did not see more than one request from Google's servers. UrlFetchApp is not sending too many requests.
It sounds like my IP is somehow blacklisted only when used with UrlFetchApp. Perhaps it thinks it is a proxy? Yet, a VPN works.
Code:
function retrieveData($id)
{
var $id = 24;
var $options = {muteHttpExceptions: true};
var $link = "https://api.guildwars2.com/v2";
var $jsonData = UrlFetchApp.fetch($link); //throws 429 error here
var $jsonString = $jsonData.getContentText();
var parsedJsonData = JSON.parse($jsonString);
console.log($jsonString);
var range = SpreadsheetApp.getActiveSpreadsheet().getRange("A1");
range.setValue($jsonString);
}