Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A Problems with Google Apps Script API JavaScript "How to... Execute function"

TL;DR: Use the versioned deployment id instead of the script id. After repeating the procedures, step by step multiple times, I tried adding the resource.devMode property to the Apps Script REST...

posted 11mo ago by Wicket‭  ·  edited 11mo ago by Wicket‭

Answer
#4: Post edited by user avatar Wicket‭ · 2023-06-29T15:00:04Z (11 months ago)
Added TL;DR, added notes.
  • After repeating the procedures, step by step multiple times, I tried adding the `devMode` parameter to the Apps Script Execution API call and setting it to `true`. This call is in `index.js` file and refers to `gapi.client.script.scripts.run`. The modified call looks as shown below
  • ```javascript
  • gapi.client.script.scripts.run({
  • 'scriptId': scriptId,
  • 'resource': {
  • 'function': 'getFoldersUnderRoot',
  • 'devMode': true
  • }
  • ```
  • Surprisingly, with this parameter, the code work. For those new to Apps Script, the development mode only works for the project owner for projects stored in My Drive units and for users having edit access for projects stored in Shared Drives, so this "solution" can't be used on "production".
  • After sleeping one night, I tried replacing the script id with the deployment id, without the `devMode` parameter... **Voila! It worked!**.
  • So the documentation on the following page looks to be incomplete.
  • https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters
  • Current content:
  • ### Path parameters
  • #### Parameters
  • <table>
  • <tr>
  • <td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
  • </tr>
  • </table>
  • The description should say that the script ID work when using `devMode`, and it's set to `true`. When it's omitted or set to `false`, use the deployment id instead of the script id.
  • The deployment id is shown when creating a new deployment. Can be found by opening Google Apps Script, opening the project, and clicking on Deploy > Manage Deployments. The dialog shows the deployment id and a button to copy it to the clipboard.
  • TL;DR: Use the **versioned deployment id** instead of the script id.
  • ---
  • After repeating the procedures, step by step multiple times, I tried adding the `resource.devMode` property to the Apps Script REST API call and setting it to `true`. This call is in `index.js` file and refers to `gapi.client.script.scripts.run`. The modified call looks as shown below
  • ```javascript
  • gapi.client.script.scripts.run({
  • 'scriptId': scriptId,
  • 'resource': {
  • 'function': 'getFoldersUnderRoot',
  • 'devMode': true
  • }
  • ```
  • Surprisingly, with this parameter, the code work. For those new to Apps Script, the development mode only works for the project owner for projects stored in My Drive units and for users having edit access for projects stored in Shared Drives, so this "solution" can't be used on "production".
  • After sleeping one night, I tried replacing the script id with the deployment id, without the `devMode` parameter... **Voila! It worked!**.
  • So the documentation on the following page looks to be incomplete.
  • https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters
  • Current content:
  • ### Path parameters
  • #### Parameters
  • <table>
  • <tr>
  • <td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
  • </tr>
  • </table>
  • The description should say that the script ID, the *head deployment id*, works when using `resource.devMode`, and it's set to `true`. When omitted or set to `false`, *use the **versioned deployment id*** instead of the script id.
  • The *versioned deployment id* is shown when creating a new deployment. Can be found by opening Google Apps Script, opening the project, and clicking on Deploy > Manage Deployments. The dialog shows the versioned deployment id and a button to copy it to the clipboard.
  • ---
  • Notes:
  • I found this question ["Requested entity was not found." - Apps Script Execution API error](https://stackoverflow.com/q/49206863/1595451). I got the idea of using `resource.devMode` property from [Tanaike's answer](https://stackoverflow.com/a/49207288/1595451).
#3: Post edited by user avatar Wicket‭ · 2023-06-29T00:49:59Z (11 months ago)
  • After repeating the procedures, step by step multiple times, I tried adding the `devMode` parameter to the Apps Script Execution API call and setting it to `true`. This call is in `index.js` file and refers to `gapi.client.script.scripts.run`. The modified call looks as shown below
  • ```javascript
  • gapi.client.script.scripts.run({
  • 'scriptId': scriptId,
  • 'resource': {
  • 'function': 'getFoldersUnderRoot',
  • 'devMode': true
  • }
  • ```
  • Surprisingly, with this parameter, the code work.
  • After sleeping one night, I tried replacing the script id with the deployment id, without the `devMode` parameter... **Voila! It worked!**.
  • So the documentation on the following page looks to be incomplete.
  • https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters
  • Current content:
  • ### Path parameters
  • #### Parameters
  • <table>
  • <tr>
  • <td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
  • </tr>
  • </table>
  • The description should say that the script ID work when using `devMode`, and it's set to `true`. When it's omitted or set to `false`, use the deployment id instead of the script id.
  • The deployment id is shown when creating a new deployment. Can be found by opening Google Apps Script, opening the project, and clicking on Deploy > Manage Deployments. The dialog shows the deployment id and a button to copy it to the clipboard.
  • After repeating the procedures, step by step multiple times, I tried adding the `devMode` parameter to the Apps Script Execution API call and setting it to `true`. This call is in `index.js` file and refers to `gapi.client.script.scripts.run`. The modified call looks as shown below
  • ```javascript
  • gapi.client.script.scripts.run({
  • 'scriptId': scriptId,
  • 'resource': {
  • 'function': 'getFoldersUnderRoot',
  • 'devMode': true
  • }
  • ```
  • Surprisingly, with this parameter, the code work. For those new to Apps Script, the development mode only works for the project owner for projects stored in My Drive units and for users having edit access for projects stored in Shared Drives, so this "solution" can't be used on "production".
  • After sleeping one night, I tried replacing the script id with the deployment id, without the `devMode` parameter... **Voila! It worked!**.
  • So the documentation on the following page looks to be incomplete.
  • https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters
  • Current content:
  • ### Path parameters
  • #### Parameters
  • <table>
  • <tr>
  • <td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
  • </tr>
  • </table>
  • The description should say that the script ID work when using `devMode`, and it's set to `true`. When it's omitted or set to `false`, use the deployment id instead of the script id.
  • The deployment id is shown when creating a new deployment. Can be found by opening Google Apps Script, opening the project, and clicking on Deploy > Manage Deployments. The dialog shows the deployment id and a button to copy it to the clipboard.
#2: Post edited by user avatar Wicket‭ · 2023-06-29T00:45:34Z (11 months ago)
  • After repeating the procedures, step by step multiple times, I tried adding the devMode parameter and setting it to true. Surprisingly, with this parameter, the code work.
  • After sleeping one night, I decided to try replacing the script id with the deployment id, without the `devMode` parameter... voila! it worked.
  • So the documentation on the following page looks to be incomplete.
  • https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters
  • Current content:
  • ### Path parameters
  • #### Parameters
  • <table>
  • <tr>
  • <td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
  • </tr>
  • </table>
  • The description should say that the script ID work when using devMode and it's set to true. When it's omitted or set to false, use the deployment id instead of the script id.
  • TODO: Add a screenshot
  • After repeating the procedures, step by step multiple times, I tried adding the `devMode` parameter to the Apps Script Execution API call and setting it to `true`. This call is in `index.js` file and refers to `gapi.client.script.scripts.run`. The modified call looks as shown below
  • ```javascript
  • gapi.client.script.scripts.run({
  • 'scriptId': scriptId,
  • 'resource': {
  • 'function': 'getFoldersUnderRoot',
  • 'devMode': true
  • }
  • ```
  • Surprisingly, with this parameter, the code work.
  • After sleeping one night, I tried replacing the script id with the deployment id, without the `devMode` parameter... **Voila! It worked!**.
  • So the documentation on the following page looks to be incomplete.
  • https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters
  • Current content:
  • ### Path parameters
  • #### Parameters
  • <table>
  • <tr>
  • <td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
  • </tr>
  • </table>
  • The description should say that the script ID work when using `devMode`, and it's set to `true`. When it's omitted or set to `false`, use the deployment id instead of the script id.
  • The deployment id is shown when creating a new deployment. Can be found by opening Google Apps Script, opening the project, and clicking on Deploy > Manage Deployments. The dialog shows the deployment id and a button to copy it to the clipboard.
#1: Initial revision by user avatar Wicket‭ · 2023-06-28T23:27:41Z (11 months ago)
After repeating the procedures, step by step multiple times, I tried adding the devMode parameter and setting it to true. Surprisingly, with this parameter, the code work.

After sleeping one night, I decided to try replacing the script id with the deployment id, without the `devMode` parameter... voila! it worked. 

So the documentation on the following page looks to be incomplete.

https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#path-parameters

Current content:

### Path parameters
#### Parameters
<table>
<tr>
<td>scriptId</td><td>string</td><td>The script ID of the script to be executed. Find the script ID on the Project settings page under "IDs."</td>
</tr>
</table>

The description should say that the script ID work when using devMode and it's set to true. When it's omitted or set to false, use the deployment id instead of the script id.

TODO: Add a screenshot