0
votes

Goal: create an apps script web app that opens a google doc and returns it's name

This functionality stopped working sometime in the last month or so.

  • create apps script project
  • add a doGet
function doGet(e) {
    var msg = "none;";
    try{
      var doc = DocumentApp.openById("1WYNw9IPcsYZXrvK7gOaoOLt7GPiaUhCJ5OEf79h~~~~"); 
      msg = doc.getName();
    }catch(e){
      msg = e;
    }  
    return HtmlService.createHtmlOutput(msg);  
}

Save and follow path for authentication

Publish / Deploy as web app with settings

  • new version because anon unable to use dev version of url
  • execute as me
  • Anyone, even anonymous

Now try it out

  • open the url in authenticated browser
    • not the test url
    • success

Found and opened Intro

open the url in incognito and do not login to any account

Error message

Exception: We're sorry, a server error occurred. Please wait a bit and try again.

Edit : added the line msg = doc.getName();

1
It does not show any error. Can you provide more information?Kessy
added msg = doc.getName(); then still no error???Rob Foree

1 Answers

1
votes

This works for me even including a new incognito window and another account.

function doGet(e) {
    var msg = "none;";
    try{
      var doc = DocumentApp.openById("docid"); 
      msg = doc.getName();
    }catch(e){
      msg = e;
    }  
    return ContentService.createTextOutput(msg);
}