| <html><body> |
| <style> |
| |
| body, h1, h2, h3, div, span, p, pre, a { |
| margin: 0; |
| padding: 0; |
| border: 0; |
| font-weight: inherit; |
| font-style: inherit; |
| font-size: 100%; |
| font-family: inherit; |
| vertical-align: baseline; |
| } |
| |
| body { |
| font-size: 13px; |
| padding: 1em; |
| } |
| |
| h1 { |
| font-size: 26px; |
| margin-bottom: 1em; |
| } |
| |
| h2 { |
| font-size: 24px; |
| margin-bottom: 1em; |
| } |
| |
| h3 { |
| font-size: 20px; |
| margin-bottom: 1em; |
| margin-top: 1em; |
| } |
| |
| pre, code { |
| line-height: 1.5; |
| font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; |
| } |
| |
| pre { |
| margin-top: 0.5em; |
| } |
| |
| h1, h2, h3, p { |
| font-family: Arial, sans serif; |
| } |
| |
| h1, h2, h3 { |
| border-bottom: solid #CCC 1px; |
| } |
| |
| .toc_element { |
| margin-top: 0.5em; |
| } |
| |
| .firstline { |
| margin-left: 2 em; |
| } |
| |
| .method { |
| margin-top: 1em; |
| border: solid 1px #CCC; |
| padding: 1em; |
| background: #EEE; |
| } |
| |
| .details { |
| font-weight: bold; |
| font-size: 14px; |
| } |
| |
| </style> |
| |
| <h1><a href="script_v1.html">Google Apps Script Execution API</a> . <a href="script_v1.scripts.html">scripts</a></h1> |
| <h2>Instance Methods</h2> |
| <p class="toc_element"> |
| <code><a href="#run">run(scriptId, body, x__xgafv=None)</a></code></p> |
| <p class="firstline">Runs a function in an Apps Script project. The project must be deployed</p> |
| <h3>Method Details</h3> |
| <div class="method"> |
| <code class="details" id="run">run(scriptId, body, x__xgafv=None)</code> |
| <pre>Runs a function in an Apps Script project. The project must be deployed |
| for use with the Apps Script Execution API. |
| |
| This method requires authorization with an OAuth 2.0 token that includes at |
| least one of the scopes listed in the [Authorization](#authorization) |
| section; script projects that do not require authorization cannot be |
| executed through this API. To find the correct scopes to include in the |
| authentication token, open the project in the script editor, then select |
| **File > Project properties** and click the **Scopes** tab. |
| |
| Args: |
| scriptId: string, The project key of the script to be executed. To find the project key, open |
| the project in the script editor and select **File > Project properties**. (required) |
| body: object, The request body. (required) |
| The object takes the form of: |
| |
| { # A request to run the function in a script. The script is identified by the |
| # specified `script_id`. Executing a function on a script returns results |
| # based on the implementation of the script. |
| "function": "A String", # The name of the function to execute in the given script. The name does not |
| # include parentheses or parameters. |
| "devMode": True or False, # If `true` and the user is an owner of the script, the script runs at the |
| # most recently saved version rather than the version deployed for use with |
| # the Execution API. Optional; default is `false`. |
| "parameters": [ # The parameters to be passed to the function being executed. The object type |
| # for each parameter should match the expected type in Apps Script. |
| # Parameters cannot be Apps Script-specific object types (such as a |
| # `Document` or a `Calendar`); they can only be primitive types such as |
| # `string`, `number`, `array`, `object`, or `boolean`. Optional. |
| "", |
| ], |
| "sessionState": "A String", # For Android add-ons only. An ID that represents the user's current session |
| # in the Android app for Google Docs or Sheets, included as extra data in the |
| # [`Intent`](https://developer.android.com/guide/components/intents-filters.html) |
| # that launches the add-on. When an Android add-on is run with a session |
| # state, it gains the privileges of a |
| # [bound](https://developers.google.com/apps-script/guides/bound) script — |
| # that is, it can access information like the user's current cursor position |
| # (in Docs) or selected cell (in Sheets). To retrieve the state, call |
| # `Intent.getStringExtra("com.google.android.apps.docs.addons.SessionState")`. |
| # Optional. |
| } |
| |
| x__xgafv: string, V1 error format. |
| Allowed values |
| 1 - v1 error format |
| 2 - v2 error format |
| |
| Returns: |
| An object of the form: |
| |
| { # 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). |
| # <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> |
| # <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> |
| # <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> |
| "metadata": { # This field is not used. |
| "a_key": "", # Properties of the object. Contains field @type with type URL. |
| }, |
| "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. |
| "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. |
| "code": 42, # The status code. For this API, this value will always be 3, corresponding to an INVALID_ARGUMENT error. |
| "details": [ # An array that contains a single `ExecutionError` object that provides information about the nature of the error. |
| { |
| "a_key": "", # Properties of the object. Contains field @type with type URL. |
| }, |
| ], |
| }, |
| "done": True or False, # This field is not used. |
| "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. |
| "a_key": "", # Properties of the object. Contains field @type with type URL. |
| }, |
| "name": "A String", # This field is not used. |
| }</pre> |
| </div> |
| |
| </body></html> |