Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"function not found" error when making both GET and POST requests to a Web App

I'm getting a

Script function not found: doGet 

OR

Script function not found: doPost 

when I GET/POST to my Google script:

function doGet(e){return ContentService.createTextOutput("User says")}  function doPost(e) {   return HtmlService.createHtmlOutput(     "<form action='http://www.example.com/users/gmail_permission/' method='post' id='foo'>" +      "<input type='hidden' name='gmail' value='getEmail()' >" +     "<input type='hidden' name='id' value='e.parameter.user_id' >" +         "</form>" +     "<script>document.getElementById('foo').submit();</script>"); }  function getEmail() {   return Session.getActiveUser().getEmail(); } 

The weird thing is I'll get the above error when I visit the Webapp URL on my browser. But when I use Hurl.it, I just get redirected to Google Drive. But when I 'Test web app for your latest code.' on google.script.com, the GET response works fine.

Pretty lost as to what is going on.... here is my script:

 https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec 

Here are the GETs

 FROM Hurl.it - GET https://accounts.google.com/ServiceLogin?service=wise&followup=https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec&continue=https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec&passive=1209600   FROM script.google.com: https://script.google.com/macros/s/AKfycbyCH4Jk7VcEIhE52jIorIBzcghRYAPRuwuzFSHwaWIB/dev   FROM browser:https://script.google.com/macros/s/AKfycbz0XGeoEuP4V6W60N7yP-dDiLltPefxmqzhMJurnGzOhPfqA_er/exec 
like image 368
echan00 Avatar asked Mar 24 '14 18:03

echan00


2 Answers

Finally found the answer.

It's pretty stupid, but apparently saving and republishing your google script web app is not good enough. You need to save a new version and publish the new version to make sure your app gets updated properly.

enter image description here

like image 178
echan00 Avatar answered Sep 21 '22 11:09

echan00


Make sure you have saved the project, otherwise you can face the same issue. I faced the same because I didn't save the file before deploying.

like image 39
mr_bkp Avatar answered Sep 22 '22 11:09

mr_bkp