Skip to content

Request to Google Apps Script URL for deployed WebApp produces 404 error

This issue is very similar to others (like Google Drive Page Not Found – Sorry, unable to open the file at this time for example) posted here. It’s not exactly the same, but I do believe it has the same root issue illustrated in that post in that trying to submit a form to a Google App Script while logged into more than to 1 Google account causes /u/1 and/or /u/0 to be added to the script’s URL thus producing a 404 Error.

This is using a standard Google account – not G-Suite.

I have a form on a website that submits to a Google Apps Script via AJAX. The script makes some API calls to create a Google Doc containing the data collected by the form.


  <input type="text" name="full_name">
  <input type="text" name="phone">
  <input type="submit">

$('form').submit(function() {
  var obj = $(this).serializeObject();
  var gurl = "";

    url: gurl,
    type: "GET",
    data: obj,
    dataType: "jsonp",
    success: function(data, status, xhr) {


function doGet(e) {
  var params = e.parameters
  var result = {};
  try {
    result = {
      status: start(params),
      msg: 'Success',
      vals: formData,
      rawVals: params,
      errs: errors
  } catch (f) {
    result.error = f.toString();
 return ContentService     
  .createTextOutput(e.parameters.callback + '(' + JSON.stringify(result) + ')')

Submitting the form while logged into more than 1 Google account in the same browser results in the following error in the console and the form does nothing:

jquery.js?ver=1.12.4-wp:4 GET net::ERR_ABORTED 404

When I go to Network tab to view the request, the Header tab there shows the following:

Request URL:

Notice the /u/1/ that have been inserted into the URL that are not present in the URL I pass to my $.ajax() call.

Most of the answers I’ve found for this issue say to just remove the /u/1/, but since I didn’t add it in the 1st place, I don’t know where I would remove it from.

Can anyone confirm that this seemingly known issue (of having the URL altered when logged into multiple Google accounts) is what is causing my problems? Any ideas as to how I can go about making my request to:

and not

?? or is there something more deeply wrong with the way I’m trying to use Google Scripts here?



My solution was to move the request from the client side to the server. I submit my form values to a server-side page via AJAX and then on that page, I make an HTTP request with cURL to my Google Apps Script (sending the form data in the body) and send the response back to the client.

Seems to be working… no issues I can think of but that doesn’t mean they don’t exist. If there are any holes to be shot in that approach, please feel free to unload.

Watered down…


    url: '/ajax-handler.php',
    type: "POST",
    data: obj
    success: function(data, status, xhr) {


$vals = my_sanitize_func($_POST);

$url = GAS_URL;
$fields = $vals;

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($fields));

//execute post
$result = curl_exec($ch);

//close connection

// handle/format response;
$result = ...

print $result;
User contributions licensed under: CC BY-SA
4 People found this is helpful