1<html><body> 2<style> 3 4body, h1, h2, h3, div, span, p, pre, a { 5 margin: 0; 6 padding: 0; 7 border: 0; 8 font-weight: inherit; 9 font-style: inherit; 10 font-size: 100%; 11 font-family: inherit; 12 vertical-align: baseline; 13} 14 15body { 16 font-size: 13px; 17 padding: 1em; 18} 19 20h1 { 21 font-size: 26px; 22 margin-bottom: 1em; 23} 24 25h2 { 26 font-size: 24px; 27 margin-bottom: 1em; 28} 29 30h3 { 31 font-size: 20px; 32 margin-bottom: 1em; 33 margin-top: 1em; 34} 35 36pre, code { 37 line-height: 1.5; 38 font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; 39} 40 41pre { 42 margin-top: 0.5em; 43} 44 45h1, h2, h3, p { 46 font-family: Arial, sans serif; 47} 48 49h1, h2, h3 { 50 border-bottom: solid #CCC 1px; 51} 52 53.toc_element { 54 margin-top: 0.5em; 55} 56 57.firstline { 58 margin-left: 2 em; 59} 60 61.method { 62 margin-top: 1em; 63 border: solid 1px #CCC; 64 padding: 1em; 65 background: #EEE; 66} 67 68.details { 69 font-weight: bold; 70 font-size: 14px; 71} 72 73</style> 74 75<h1><a href="script_v1.html">Google Apps Script Execution API</a> . <a href="script_v1.scripts.html">scripts</a></h1> 76<h2>Instance Methods</h2> 77<p class="toc_element"> 78 <code><a href="#run">run(scriptId, body, x__xgafv=None)</a></code></p> 79<p class="firstline">Runs a function in an Apps Script project. The project must be deployed</p> 80<h3>Method Details</h3> 81<div class="method"> 82 <code class="details" id="run">run(scriptId, body, x__xgafv=None)</code> 83 <pre>Runs a function in an Apps Script project. The project must be deployed 84for use with the Apps Script Execution API. 85 86This method requires authorization with an OAuth 2.0 token that includes at 87least one of the scopes listed in the [Authorization](#authorization) 88section; script projects that do not require authorization cannot be 89executed through this API. To find the correct scopes to include in the 90authentication token, open the project in the script editor, then select 91**File > Project properties** and click the **Scopes** tab. 92 93Args: 94 scriptId: string, The project key of the script to be executed. To find the project key, open 95the project in the script editor and select **File > Project properties**. (required) 96 body: object, The request body. (required) 97 The object takes the form of: 98 99{ # A request to run the function in a script. The script is identified by the 100 # specified `script_id`. Executing a function on a script returns results 101 # based on the implementation of the script. 102 "function": "A String", # The name of the function to execute in the given script. The name does not 103 # include parentheses or parameters. 104 "devMode": True or False, # If `true` and the user is an owner of the script, the script runs at the 105 # most recently saved version rather than the version deployed for use with 106 # the Execution API. Optional; default is `false`. 107 "parameters": [ # The parameters to be passed to the function being executed. The object type 108 # for each parameter should match the expected type in Apps Script. 109 # Parameters cannot be Apps Script-specific object types (such as a 110 # `Document` or a `Calendar`); they can only be primitive types such as 111 # `string`, `number`, `array`, `object`, or `boolean`. Optional. 112 "", 113 ], 114 "sessionState": "A String", # For Android add-ons only. An ID that represents the user's current session 115 # in the Android app for Google Docs or Sheets, included as extra data in the 116 # [`Intent`](https://developer.android.com/guide/components/intents-filters.html) 117 # that launches the add-on. When an Android add-on is run with a session 118 # state, it gains the privileges of a 119 # [bound](https://developers.google.com/apps-script/guides/bound) script — 120 # that is, it can access information like the user's current cursor position 121 # (in Docs) or selected cell (in Sheets). To retrieve the state, call 122 # `Intent.getStringExtra("com.google.android.apps.docs.addons.SessionState")`. 123 # Optional. 124 } 125 126 x__xgafv: string, V1 error format. 127 Allowed values 128 1 - v1 error format 129 2 - v2 error format 130 131Returns: 132 An object of the form: 133 134 { # The response will not arrive until the function finishes executing. The maximum runtime is listed in the guide to [limitations in Apps Script](https://developers.google.com/apps-script/guides/services/quotas#current_limitations). 135 # <p>If the script function returns successfully, the `response` field will contain an `ExecutionResponse` object with the function's return value in the object's `result` field.</p> 136 # <p>If the script function (or Apps Script itself) throws an exception, the `error` field will contain a `Status` object. The `Status` object's `details` field will contain an array with a single `ExecutionError` object that provides information about the nature of the error.</p> 137 # <p>If the `run` call itself fails (for example, because of a malformed request or an authorization error), the method will return an HTTP response code in the 4XX range with a different format for the response body. Client libraries will automatically convert a 4XX response into an exception class.</p> 138 "metadata": { # This field is not used. 139 "a_key": "", # Properties of the object. Contains field @type with type URL. 140 }, 141 "error": { # If a `run` call succeeds but the script function (or Apps Script itself) throws an exception, the response body's `error` field will contain this `Status` object. # If a `run` call succeeds but the script function (or Apps Script itself) throws an exception, this field will contain a `Status` object. The `Status` object's `details` field will contain an array with a single `ExecutionError` object that provides information about the nature of the error. 142 "message": "A String", # A developer-facing error message, which is in English. Any user-facing error message is localized and sent in the [`google.rpc.Status.details`](google.rpc.Status.details) field, or localized by the client. 143 "code": 42, # The status code. For this API, this value will always be 3, corresponding to an INVALID_ARGUMENT error. 144 "details": [ # An array that contains a single `ExecutionError` object that provides information about the nature of the error. 145 { 146 "a_key": "", # Properties of the object. Contains field @type with type URL. 147 }, 148 ], 149 }, 150 "done": True or False, # This field is not used. 151 "response": { # If the script function returns successfully, this field will contain an `ExecutionResponse` object with the function's return value as the object's `result` field. 152 "a_key": "", # Properties of the object. Contains field @type with type URL. 153 }, 154 "name": "A String", # This field is not used. 155 }</pre> 156</div> 157 158</body></html>