Before you can begin any of the quickstarts, you will need a target Apps Script for the API to call. Follow these steps to create a simple script and enable it for API access.
Step 1: Create the script
- Open the Apps Script editor and create a blank project.
- Click on the "Untitled Project" title to rename the script. Name the script "Apps Script Execution API Quickstart Target" and click OK.
-
Replace the contents of the
Code.gsfile with the following:/** * The function in this script will be called by the Apps Script Execution API. */ /** * Return the set of folder names contained in the user's root folder as an * object (with folder IDs as keys). * @return {Object} A set of folder names keyed by folder ID. */ function getFoldersUnderRoot() { var root = DriveApp.getRootFolder(); var folders = root.getFolders(); var folderSet = {}; while (folders.hasNext()) { var folder = folders.next(); folderSet[folder.getId()] = folder.getName(); } return folderSet; } -
Save the project by selecting File > Save.
Step 2: Publish the script for execution
- In the code editor, select Publish > Deploy as API executable.
- In the dialog that opens, leave the Version as "New" and enter "Target-v1" into the text box. Click Deploy.
Step 3: Choose a quickstart
Each of these quickstarts use the Apps Script Execution API to call the script you just created: