Exception: Request failed for https://archives.nseindia.com returned code 403.

457 views
Skip to first unread message

Krishna Soni

unread,
Jan 3, 2023, 2:30:23 PM1/3/23
to Google Apps Script Community
Earlier my funtion code was working fine till the 30 Dec 2022, but now it is throwing error as following -
Message details
Exception: Request failed for https://archives.nseindia.com returned code 403. Truncated server response: <HTML><HEAD> <TITLE>Access Denied</TITLE> </HEAD><BODY> <H1>Access Denied</H1> You don't have permission to access "http&#58;&#47;&#47;archives&#... (use muteHttpExceptions option to examine full response).

 If still I change highlighted date in url then it works fine for the date befor 01 Jan 2023 but when i set date after 30 Dec 2023 then it throwing error, In this same funtion many other url are working fine like "https://archives.nseindia.com/content/fo/fo.zip"-  friends Can any one help me to rectify it.

Code
function fetchData() {
  var zipblob = UrlFetchApp.fetch(url).getBlob();
  var unzipblob = Utilities.unzip(zipblob);
  var unzipstr = unzipblob[0].getDataAsString();
  var csv = Utilities.parseCsv(unzipstr);
  sheet.getRange('A7:O').clearContent();
  sheet.getRange(6, 1, csv.length, csv[0].length).setValues(csv);
}

cwl...@gmail.com

unread,
Jan 4, 2023, 7:06:45 AM1/4/23
to Google Apps Script Community
I'm guessing it is a problem with the site or the filenames on the site. I went there and was able to manually download Dec 28, but not Jan 3. So I think your code it good.
Reply all
Reply to author
Forward
0 new messages