Report: Recent Value of ScriptApp.getService().getUrl() in Google Apps Script

There is a method of ScriptApp.getService().getUrl() for obtaining the Web Apps URL in Google Apps Script.

  • Before the V8 runtime is released, this method had returned the endpoint like https://script.google.com/macros/s/{deploymentId}/exec.

  • After the V8 runtime was released, the endpoint of https://script.google.com/macros/s/{deploymentId}/dev was returned.

  • Now, it seems that this returns https://script.google.com/macros/s/###/exec.

But, in the current stage, when I access this endpoint, the message of Sorry, unable to open the file at this time. Please check the address and try again. is returned. So, I tried to search the deployment ID of ### from https://script.google.com/macros/s/###/exec returned with current ScriptApp.getService().getUrl(). But, unfortunately, I cannot find the deployment ID. I’m worried that this might be related to the error.

In order to test this situation, I used the following sample script to the standalone script.

function doGet() {
  return HtmlService.createHtmlOutput("Done.");
}

function getUrl() {
  console.log(ScriptApp.getService().getUrl());
}
  • When this is deployed as Web Apps, the URL of https://script.google.com/macros/s/{deploymentId1}/exec is obtained. This can be found with “projects.deployments.list” of Apps Script API. And, when I access this URL, Done is shown.

  • On the other hand, when getUrl() is run, https://script.google.com/macros/s/{deploymentId2 ?}/exec is obtained. But, this deployment ID cannot be found with “projects.deployments.list” of Apps Script API. And, when I access this URL, Sorry, unable to open the file at this time. Please check the address and try again. is shown.

Can you replicate it? If my test was not correct, if you tell me it, I’m glad.

Added

I have reported this to Google issue tracker as a bug. https://issuetracker.google.com/issues/235862472

 Share!