Method: projects.updateContent
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
更新指定脚本项目的内容。此内容以 HEAD 版本的形式存储,并在脚本作为触发器、脚本编辑器或插件预览模式中执行时使用,或者在开发模式下作为 Web 应用或 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 概览。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):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)."]]