Quản lý dự án
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.
Phần này cung cấp thông tin tổng quan về các phương thức API Apps Script mà bạn có thể dùng để tạo, đọc, sửa đổi và theo dõi các dự án Apps Script. Trang mẫu Quản lý dự án cho thấy các ví dụ về yêu cầu quản lý API. Tài liệu tham khảo cho từng phương thức cung cấp thông tin chi tiết về cách triển khai.
Tổng quan về phương thức API |
Tạo dự án |
projects.create
Kết quả: Tạo một dự án cơ bản, trống không có tệp dự án và một tệp kê khai dự án mặc định.
Tuỳ chọn: Bạn có thể cung cấp tiêu đề dự án. Bạn cũng có thể tạo một tập lệnh liên kết bằng cách cung cấp mã nhận dạng Google Drive của một tệp Google Tài liệu, Google Trang tính, Google Biểu mẫu hoặc Trang trình bày để đóng vai trò là tệp mẹ của tập lệnh.
|
Đọc siêu dữ liệu của dự án |
projects.get
Kết quả: Truy xuất một đối tượng
Project . Đối tượng này biểu thị siêu dữ liệu của dự án. Dữ liệu này bao gồm tiêu đề dự án, mã tập lệnh, người dùng tạo, thời gian tạo và các thông tin chi tiết khác.
|
Đọc nội dung dự án |
projects.getContent
Results (Kết quả): Trả về một mảng gồm các đối tượng File , mỗi đối tượng cho một mã và tệp HTML trong dự án. Danh sách này cũng bao gồm tệp kê khai dự án dưới dạng tệp JSON. Các đối tượng tệp chứa nội dung nguồn của tệp (File.source ) và siêu dữ liệu khác, chẳng hạn như danh sách các hàm trong tệp (File.functionSet ).
Lựa chọn: Bạn có thể chỉ định phiên bản nội dung cần truy xuất bằng một tham số truy vấn.
|
Cập nhật nội dung dự án |
projects.updateContent
Kết quả: Thay đổi nội dung tệp trong một dự án tập lệnh.
Bạn cung cấp nội dung mới dưới dạng một mảng các đối tượng File . Một trong các đối tượng File này phải có loại JSON và biểu thị tệp kê khai dự án mới của dự án tập lệnh. Nội dung mới được lưu trữ dưới dạng phiên bản HEAD của dự án. Được dùng khi tập lệnh thực thi dưới dạng một đ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 một ứng dụng web hoặc Apps Script API ở chế độ phát triển.
Lưu ý: Khi cập nhật nội dung dự án tập lệnh, thông thường, bạn nên đưa ra yêu cầu
projects.getContent trước để truy xuất một mảng gồm các File hiện có, thực hiện yêu cầu đối với các đối tượng đó, sau đó dùng File làm dữ liệu đầu vào cho yêu cầu
projects.updateContent.
Cảnh báo: Nội dung mới sẽ thay thế tất cả các tệp hiện có trong dự án tập lệnh. Những tệp không được yêu cầu cập nhật sẽ bị xoá.
|
Đọc các chỉ số của dự án |
projects.getMetrics
Kết quả: Đọc một số chỉ số về một dự án.
Các chỉ số này bao gồm số người dùng, tổng số lần thực thi, tổng số lỗi thực thi và các thông tin chi tiết khác.
Sử dụng
MetricType để chỉ định thông tin mà bạn đang yêu cầu.
Lựa chọn: Giới hạn kết quả ở các hoạt động triển khai hoặc hàm tập lệnh cụ thể bằng cách sử dụng
MetricsFilter.
Bạn cũng có thể xác định một khoảng thời gian cụ thể cho chỉ số bằng cách sử dụng
MetricsIntervalConfig.
|
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-08-31 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eThis section outlines Apps Script API methods for managing Apps Script projects, including creating, reading, updating, and monitoring.\u003c/p\u003e\n"],["\u003cp\u003eYou can create new projects, retrieve project metadata and content, and update project files using these methods.\u003c/p\u003e\n"],["\u003cp\u003eThe API allows you to access project metrics like user count, executions, and errors for analysis.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided links for detailed documentation and code samples on project management requests.\u003c/p\u003e\n"]]],[],null,["# Managing Projects\n\nThis section provides an overview of the Apps Script API methods\nyou can use to create, read, modify,\nand monitor your Apps Script projects. The\n[Project Management](/apps-script/api/samples/manage)\nsamples page shows examples of API management requests. The reference\ndocumentation for each method provides implementation details.\n\n| **API method overview** ||\n|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Create projects** | [projects.create](/apps-script/api/reference/rest/v1/projects/create) **Results** : Create a basic, empty project with no project files and a default [project manifest](/apps-script/concepts/manifests). **Options** : You can provide a project title. You can also create a [bound script](/apps-script/guides/bound) by providing the Google Drive ID of a Google Docs, Google Sheets, Google Forms, or Slides file to act as the script's parent. |\n| **Read project metadata** | [projects.get](/apps-script/api/reference/rest/v1/projects/get) **Results** : Retrieves a [`Project`](/apps-script/api/reference/rest/v1/projects#Project) object, which represents project metadata. This data includes the project title, script ID, creating user, creation time, and other details. |\n| **Read project content** | [projects.getContent](/apps-script/api/reference/rest/v1/projects/getContent) **Results** : Returns an array of [`File`](/apps-script/api/reference/rest/v1/File) objects, one for each code and HTML file in the project. The list also includes the [project manifest](/apps-script/concepts/manifests) as a JSON file. File objects contain the source content of the file (`File.source`) and other metadata, such a list of functions in the file (`File.functionSet`). **Options** : You can specify which [version](/apps-script/guides/versions) of the content to retrieve with a query parameter. |\n| **Update project content** | [projects.updateContent](/apps-script/api/reference/rest/v1/projects/updateContent) **Results** : Changes the file content in a script project. You provide the new content as an array of [`File`](/apps-script/api/reference/rest/v1/File) objects. One of these `File` objects must have JSON type and represent the script project's new [project manifest](/apps-script/concepts/manifests). The new content is stored as the HEAD version of the project. It is used when the script executes as a trigger, in the script editor, in add-on preview mode, or as a web app or Apps Script API in development mode. **Note** : When updating script project content, common practice is to first issue a [projects.getContent](/apps-script/api/reference/rest/v1/projects/getContent) request to retrieve an array of the existing `File`s, make the desire to those objects, then use the `File`s as input for a [projects.updateContent](/apps-script/api/reference/rest/v1/projects/updateContent) request. **Warning:** The new content replaces all existing files in the script project. Files not updated by the request are removed. |\n| **Read project metrics** | [projects.getMetrics](/apps-script/api/reference/rest/v1/projects/getMetrics) **Results** : Read certain metrics about a project. These metrics include the number of users, the total number of executions, the total number of execution errors, and other details. Use a [MetricType](/apps-script/api/reference/rest/v1/projects/getMetrics#metrictype) to specify the information you are requesting. **Options** : Restrict the results to specific deployments or script functions using a [MetricsFilter](/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsFilter). You can also define a specific metric interval using a [MetricsIntervalConfig](/api/reference/rest/v1/projects/getMetrics#metricsintervalconfig). |"]]