Method: projects.updateContent
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Cập nhật nội dung của dự án tập lệnh được chỉ định. Nội dung này được lưu trữ dưới dạng phiên bản HEAD và được dùng khi tập lệnh được thực thi dưới dạng điều kiện kích hoạt, trong trình chỉnh sửa tập lệnh, ở chế độ xem trước tiện ích bổ sung hoặc dưới dạng ứng dụng web hoặc API Apps Script ở chế độ phát triển. Thao tác này sẽ xoá tất cả tệp hiện có trong dự án.
Yêu cầu HTTP
PUT https://script.googleapis.com/v1/projects/{scriptId}/content
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Tham số |
scriptId |
string
Mã Drive của dự án tập lệnh.
|
Nội dung yêu cầu
Nội dung yêu cầu chứa dữ liệu có cấu trúc sau:
Biểu diễn dưới dạng JSON |
{
"files": [
{
object (File )
}
]
} |
Trường |
files[] |
object (File )
Danh sách các tệp dự án tập lệnh. Một trong số các tệp này là tệp kê khai tập lệnh; tập lệnh đó phải được đặt tên là "appsscript", phải có loại JSON và chứa cấu hình tệp kê khai cho dự án.
|
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một phiên bản của Content
.
Phạm vi cấp phép
Yêu cầu phạm vi OAuth sau:
https://www.googleapis.com/auth/script.projects
Để biết thêm thông tin, hãy xem bài viết Tổng quan về OAuth 2.0.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\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)."]]