45

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
ziganotschka
  • 25,866
  • 2
  • 16
  • 33
echan00
  • 2,788
  • 2
  • 18
  • 35

2 Answers2

127

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

toddmo
  • 20,682
  • 14
  • 97
  • 107
echan00
  • 2,788
  • 2
  • 18
  • 35
  • 11
    Thanks for this. I was getting so frustrated with the same problem, and this fixed my issue. – akgill Jun 18 '14 at 16:30
  • 3
    To add a new version go to ```File -> Manage versions...``` – Yuval A. May 02 '15 at 01:10
  • 9
    You don't need to goto manage versions. You can just do Publish>Deploy as Web App> and select "new" in the project version dropbox. Seriously, Google should get rid of this requirement or atleast warn developers clearly, since its not intuitive. – Sujay Phadke Jan 03 '16 at 23:03
  • 6
    I did as the answer suggests but it still doesn't work. Broken garbage. I don't think google cares about this. – Trevor Hickey Nov 26 '17 at 21:20
  • 1
    same here, I wonder why the super smart google guys didn't get that :p – TrOnNe Feb 27 '18 at 09:48
  • wow. I cant believe this is the answer. thats so frustrating. thank you – Candace Sep 23 '20 at 17:02
  • 2
    I upvoted this around 2 years ago. Today I tried to create a new app, and couldn't get it to work, and this issue had me stuck for over an hour until I found this post again... Wish I could upvote it again! – woodenflute Jan 29 '21 at 17:41
3

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.

mr_bkp
  • 61
  • 1
  • 6