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

echan00 picture echan00 · Mar 24, 2014 · Viewed 37.2k times · Source

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

Answer

echan00 picture echan00 · Mar 25, 2014

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