Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Spreadsheets "You do not have permission to call fetch" [duplicate]

I am using the script editor in google spreadsheets, and I want to be able to make a simple HTTP request, but I keep getting the following error message:

Google Apps Script: You do not have permission to call fetch

I used the onEdit Function

function onEdit(e){
  var ui = SpreadsheetApp.getUi();
        var response = UrlFetchApp.fetch('http://www.google.com/');
    Logger.log(response.getContentText());
  } 

Why am I getting this error? Any help would be appreciated.

like image 811
Mr.Banks Avatar asked Mar 07 '23 18:03

Mr.Banks


1 Answers

Simple triggers cannot use functionality that requires authorization Rename the function, then create an installed onEdit trigger for it. Call it manually within the Script Editor, proceed through the Authorization flow, and then the functionality will work as you expect.

Note that for things with quotas (such as UrlFetch), you may want to gate the call behind range checks, etc. (i.e. is event.range.getColumn() a desired value, etc).

like image 77
tehhowch Avatar answered Mar 30 '23 23:03

tehhowch