HtmlService doPost

2019-04-17 12:45发布

问题:

i am trying to submit a form using doPost but i keep getting the "Unknown macro doPost" error.

The templated Html:

<?var url = ScriptApp.getService().getUrl().replace("exec","dev");?>

...

<form action='<?=url?>' method="post">
  <fieldset>
    ...
    <input type="submit" value="Submit"/>
  </fieldset>
</form>

The script:

function doPost(requestInfo){
  Logger.log("Entering doPost()\n");
  return HtmlService.createHtmlOutput("<h1>404</h1>");

}

Any ideas why that's happening?

回答1:

You are geting error because you are posting the data to a wrong URL. Developer and Execution URL do not only differ by dev/exec. Both the URLs are totally different. To test, just hardcode the devloper URL



回答2:

Have you saved a new version and updated the webapp's version since writing the doPost function?