Method: projects.updateContent
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
更新指定指令碼專案的內容。此內容會儲存為 HEAD 版本。當指令碼做為觸發條件執行時、指令碼編輯器、外掛程式預覽模式,或開發模式下的網頁應用程式或 Apps Script API 執行時,都會使用這項內容。這會清除專案中的所有現有檔案,
HTTP 要求
PUT https://script.googleapis.com/v1/projects/{scriptId}/content
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
scriptId |
string
指令碼專案的雲端硬碟 ID。
|
要求主體
要求主體的資料會採用以下結構:
JSON 表示法 |
{
"files": [
{
object (File )
}
]
} |
欄位 |
files[] |
object (File )
指令碼專案檔案清單。其中一個檔案是指令碼資訊清單;名稱必須是「appsscript」,且必須包含 JSON 類型,且包含專案的資訊清單設定。
|
回應主體
如果成功,回應主體會包含 Content
的執行例項。
授權範圍
需要下列 OAuth 範圍:
https://www.googleapis.com/auth/script.projects
詳情請參閱 OAuth 2.0 總覽。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eUpdates the content of a specified Apps Script project, replacing all existing files.\u003c/p\u003e\n"],["\u003cp\u003eRequires a \u003ccode\u003ePUT\u003c/code\u003e request to the specified endpoint with the script project's Drive ID.\u003c/p\u003e\n"],["\u003cp\u003eThe request body must contain a list of files, including a JSON manifest named "appsscript".\u003c/p\u003e\n"],["\u003cp\u003eA successful response returns the updated project content.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/script.projects\u003c/code\u003e scope.\u003c/p\u003e\n"]]],[],null,["# Method: projects.updateContent\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization Scopes](#body.aspect)\n- [Try it!](#try-it)\n\nUpdates the content of the specified script project. This content is stored as the HEAD version, and is used when the script is executed as a trigger, in the script editor, in add-on preview mode, or as a web app or Apps Script API in development mode. This clears all the existing files in the project.\n\n### HTTP request\n\n`PUT https://script.googleapis.com/v1/projects/{scriptId}/content`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|-----------------------------------------|\n| `scriptId` | `string` The script project's Drive ID. |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------|\n| ``` { \"files\": [ { object (/apps-script/api/reference/rest/v1/File) } ] } ``` |\n\n| Fields ||\n|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `files[]` | `object (`[File](/apps-script/api/reference/rest/v1/File)`)` The list of script project files. One of the files is a script manifest; it must be named \"appsscript\", must have type of JSON, and include the manifest configurations for the project. |\n\n### Response body\n\nIf successful, the response body contains an instance of [Content](/apps-script/api/reference/rest/v1/projects/getContent#body.Content).\n\n### Authorization Scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/script.projects`\n\nFor more information, see the [OAuth 2.0 Overview](https://developers.google.com/identity/protocols/OAuth2)."]]