UrlFetchApp doGet not called and return html with

2019-08-13 02:00发布

问题:

I must be loosing my mind as suddenly I can'y get a simple webapp to work. When I use the url generated in the browser everything works fine. When I run the script the result is an html content with Meet Google Drive.

Here is the code:

function doGet(e) {
  return ContentService.createTextOutput('blabla').setMimeType(ContentService.MimeType.TEXT);  
}

function client() {
  var url = 'https://script.google.com/macros/s/AKfycby2NVrhG0O5fE6gTgage2QPYH3UJ2s23AJDLnB9YL69uyDFlmM/exec';
  Logger.log(url);
  var result = UrlFetchApp.fetch(url);
  Logger.log(result);
}

Both doGet() and the client() functions are at the same file which was never a problem. A version was saved and the app deployed as anyone accessing the app and run as user accessing the app. result.getContentText() returns the same html output. result.getResponseCode() return 200 which supposed to be successful however I can't see the doGet() being called.

Any idea what I missed?

Thanks.

回答1:

I had the same issue. When you deploy the WebApp, make sure the authorizations are set to "Anyone, including Anonymous"!