Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 1 | <html><body> |
| 2 | <style> |
| 3 | |
| 4 | body, 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 | |
| 15 | body { |
| 16 | font-size: 13px; |
| 17 | padding: 1em; |
| 18 | } |
| 19 | |
| 20 | h1 { |
| 21 | font-size: 26px; |
| 22 | margin-bottom: 1em; |
| 23 | } |
| 24 | |
| 25 | h2 { |
| 26 | font-size: 24px; |
| 27 | margin-bottom: 1em; |
| 28 | } |
| 29 | |
| 30 | h3 { |
| 31 | font-size: 20px; |
| 32 | margin-bottom: 1em; |
| 33 | margin-top: 1em; |
| 34 | } |
| 35 | |
| 36 | pre, code { |
| 37 | line-height: 1.5; |
| 38 | font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; |
| 39 | } |
| 40 | |
| 41 | pre { |
| 42 | margin-top: 0.5em; |
| 43 | } |
| 44 | |
| 45 | h1, h2, h3, p { |
| 46 | font-family: Arial, sans serif; |
| 47 | } |
| 48 | |
| 49 | h1, 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"> |
Thomas Coffee | 2f24537 | 2017-03-27 10:39:26 -0700 | [diff] [blame] | 78 | <code><a href="#run">run(scriptId, body, x__xgafv=None)</a></code></p> |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 79 | <p class="firstline">Runs a function in an Apps Script project. The project must be deployed</p> |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 80 | <h3>Method Details</h3> |
| 81 | <div class="method"> |
Thomas Coffee | 2f24537 | 2017-03-27 10:39:26 -0700 | [diff] [blame] | 82 | <code class="details" id="run">run(scriptId, body, x__xgafv=None)</code> |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 83 | <pre>Runs a function in an Apps Script project. The project must be deployed |
| 84 | for use with the Apps Script Execution API. |
| 85 | |
| 86 | This method requires authorization with an OAuth 2.0 token that includes at |
| 87 | least one of the scopes listed in the [Authorization](#authorization) |
| 88 | section; script projects that do not require authorization cannot be |
| 89 | executed through this API. To find the correct scopes to include in the |
| 90 | authentication token, open the project in the script editor, then select |
| 91 | **File > Project properties** and click the **Scopes** tab. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 92 | |
| 93 | Args: |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 94 | scriptId: string, The project key of the script to be executed. To find the project key, open |
| 95 | the project in the script editor and select **File > Project properties**. (required) |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 96 | body: object, The request body. (required) |
| 97 | The object takes the form of: |
| 98 | |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 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. |
Sai Cheemalapati | 4ba8c23 | 2017-06-06 18:46:08 -0400 | [diff] [blame^] | 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 | ], |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 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. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | x__xgafv: string, V1 error format. |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 127 | Allowed values |
| 128 | 1 - v1 error format |
| 129 | 2 - v2 error format |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 130 | |
| 131 | Returns: |
| 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). |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 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. |
Jon Wayne Parrott | 7d5badb | 2016-08-16 12:44:29 -0700 | [diff] [blame] | 139 | "a_key": "", # Properties of the object. Contains field @type with type URL. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 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. |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 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. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 144 | "details": [ # An array that contains a single `ExecutionError` object that provides information about the nature of the error. |
| 145 | { |
Jon Wayne Parrott | 7d5badb | 2016-08-16 12:44:29 -0700 | [diff] [blame] | 146 | "a_key": "", # Properties of the object. Contains field @type with type URL. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 147 | }, |
| 148 | ], |
| 149 | }, |
| 150 | "done": True or False, # This field is not used. |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 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. |
Jon Wayne Parrott | 7d5badb | 2016-08-16 12:44:29 -0700 | [diff] [blame] | 152 | "a_key": "", # Properties of the object. Contains field @type with type URL. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 153 | }, |
Sai Cheemalapati | c30d2b5 | 2017-03-13 12:12:03 -0400 | [diff] [blame] | 154 | "name": "A String", # This field is not used. |
Jon Wayne Parrott | 36e41bc | 2016-02-19 16:02:29 -0800 | [diff] [blame] | 155 | }</pre> |
| 156 | </div> |
| 157 | |
| 158 | </body></html> |