Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Service - Uncaught NetworkError: Form submission failed

I am working through the google example code for HTML Service: Communicate with Server Functions.

I can't get the sample code to work for "Forms'. Is there an error in the code or is it something in my browser config?

The code is -

code.gs

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index');
}

function processForm(formObject) {
  var formBlob = formObject.myFile;
  var driveFile = DriveApp.createFile(formBlob);
  return driveFile.getUrl();
}

index.html

<script>
  function updateUrl(url) {
    var div = document.getElementById('output');
    div.innerHTML = '<a href="' + url + '">Got it!</a>';
  }
</script>
<form id="myForm">
  <input name="myFile" type="file" />
  <input type="button" value="Submit"
      onclick="google.script.run
          .withSuccessHandler(updateUrl)
          .processForm(this.parentNode)" />
</form>
<div id="output"></div>

The error in the debug windows of my browser is

Uncaught NetworkError: Form submission failed.

Thanks in advance. Will Brown.

like image 872
Will Avatar asked Feb 14 '26 08:02

Will


1 Answers

This error is not due to a code problem at all, rather it is an interaction between a browser plug-in and Google's authentication services. See Issue 3339 and Issue 4394.

If you're using the LastPass password manager plugin, it must be disabled.


PS: @user3531933 - if you add your own answer, just leave a comment for me, and I'll happily delete this and leave it to you.

like image 198
Mogsdad Avatar answered Feb 18 '26 06:02

Mogsdad