Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script function not found: doGet

I keep getting this error message when I try to click "Test web app for your latest code." in the Publish dialog box.

But I haven't defined any function called doGet().

My code is only:

function unreadCount() {
  var unreadNum = "Messages unread in inbox: " + GmailApp.getInboxUnreadCount();
  return unreadNum
}
like image 832
Anirudh Ajith Avatar asked Mar 08 '14 17:03

Anirudh Ajith


2 Answers

Every webapp in Google Apps Script must have a main function called doGet() which is the entry point of the app, the function that your app will start with when you type the webapp url.

This is true for every application deployed as a standalone app and called by its url - with a user interface or not.

If you read the documentation you'll see that all the standalone apps examples for HTMLService or UiApp have a doGet function.

Only container embedded ui scripts or scripts that run on triggers are not concerned by this rule.

Knowing that, the error message you get is probably more meaningful isn't it ?

like image 86
Serge insas Avatar answered Sep 28 '22 02:09

Serge insas


As Serge insas said, you must first implement the function doGet(e) as described in Google's documentation.

However, after you implement it, make sure to save a new version of your project (File > Manage versions... and then save the new version) and then deploy the new version of your web app. Else you will continue to get the "doGet not implemented" error from Google. This is because it is still using the old version of your application, before you implemented doGet.

like image 35
Kayce Basques Avatar answered Sep 28 '22 02:09

Kayce Basques