HtmlService doPost

2019-04-17 13:02发布

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?

2条回答
Fickle 薄情
2楼-- · 2019-04-17 13:07

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

查看更多
一夜七次
3楼-- · 2019-04-17 13:08

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

查看更多
登录 后发表回答