Error running Google App script - google-apps-script

I created an script in https://script.google.com/
and if I open the script in the browser I get the desire result
However, If I try to included it as part of Google Site, following the steps:
Edit Site
Insert --> App Script
and pasting the URL that works above
I get the following error: It didn't get me the error before with the same script, so I'm not sure if it is because any type of limitations in the number of scripts I can run or somehting like that
Sorry, the file you have requested does not exist.
Please check the address and try again.
thank you very much

this is a very old bug in apps script. to fix, change your url "script.xxxx..." to "sites.xxxx...".

Related

Google App Scipt Utilites.unzip does not work with zip files from outside script

My Google App script that unzip attachments of a Gmail message does not work with
zip files from outside script.
When I use Utilities.unzip method, like this
var unzippedBlob =Utilities.unzip(zippedBlob);
I always end up with an error 'We're sorry, a server error occurred. Please wait a bit and try again.' since then.
Does anyone see the same error?

How do I download previous saved revisions of a Google Apps Script?

I am still attempting to recover from somehow 'loosing' a Google Apps Script when I created a copy of the script to fork the code to another project... My thought was to attempt to download older revisions of the Google Apps Script via the drive API, but this page indicates that perhaps it is not possible.
Actions such as versioning, publishing or executing the script are not available through the API.
So I attempted it anyway and alas this error occurs...
<HttpError 400 when requesting
https://www.googleapis.com/drive/v2/files/..snipped../revisions?alt=json
returned "File does not support revisions">
So is there no mechanism to download previous versions or "Revisions" of Google Apps Script? What I would love is to get access to 'Revision 1' shown here within the script.google.com interface:
This is a bit manual but:
Create another script project
Include your original script as a library in your new script and select v1
In the new script add some code that uses your "library"
Use the script editor debugger to step into the library and you should see the code from the correct version
For example if your library is called something like "MyOldCode", include some code like this in your new script:
function getOldCode() {
var a = MyOldCode.anExampleFunction()
}
Put a breakpoint below the "var a" line, run getOldCode() with the debugger and then step into anExampleFunction(). This will open up one file of your old code allowing you to copy and paste it elsewhere.
You can then piece together v1.
Edit 2019-04-11: There is also Romain's function for accessing old versions.
Edit 2022-05-05: With V8 and the new editor I can no longer find a way to step into a library. Rhino gives a server error, and V8 ignores the "step in".
FYI, the Apps Script API can get project files from a previous version number:
https://developers.google.com/apps-script/api/reference/rest/v1/projects/getContent
If you'd like to see this in the Apps Script CLI, clasp, like clasp pull 3, I'm sure I could add this feature.
https://github.com/google/clasp/
Just file a new issue.
Grant is the right answer. Clasp is the way. I just wanted to update the command for the current state of clasp which is
clasp pull --versionNumber 12

414 Error for creating trigger for google app scripts

I have some exisiting google app scripts in a spreadsheet of my google drive.
Tried to create a time driven trigger under Script Editor -> Resources to automate the execution of a script. Encountered error: 414. That’s an error.
The requested URL /... is too large to process. That’s all we know.
Read through some of the existing similar issues/solution. Nothing specific to time driven triggers found.
Anyone has a workaround ?
Have you tried running the script without the trigger? I find most times I get that error it's because I'm trying to add a trigger to a script that I haven't yet run and authorised first. Good luck!

Execute Google Apps Script as anonymous only display the button "click me"

i've a good google apps script that works well, it get parameters from GET/POST for produce pdf and send it by mail and store it in google drive.
all works fine if i execute that script by my user.
i've tryed to publish to everyone, keeping execution as my user
when i try to open the generated url i see only a button "click me"
what's wrong ??
i need to call this script from GAE for execute some stuff on docs.
anyone can help me?
this is the url of my script: script
thanks
Sandro
edit
this is my test code:
function doGet() {
var output = ContentService.createTextOutput()
.setMimeType(ContentService.MimeType.TEXT)
.setContent("Hello World");
return output; }
i've publish as webapp, execution is set to my self, access is set to everyone including anonymous.
When i try to access as anonymous user, i always saw that button :(
You didn't update the version (see the menu: File > Manage Versions) and then republish the app, so you were getting the old code (aka, the sample code you get from "script as webapp"). The test URL is always the newest code, but the real URL gets an explicit version.

Stopping the error "Authorisation is required to perform that action" in Google Apps Script

I keep getting this error message when I try to view my deployed app.
Authorisation is required to perform that action
How do I get around the error?
Services in use in the script:
ScriptDB
UiApp
(I think that is all)
I can't find the answer in the documentation, so I would be very grateful for some help.
You need to go the script editor and attempt to run any function manually first.
A first authorization popup is shown when you first deploy as web app, but if you go and change the code accessing new services you have to re-authorize it.