Method: providers.tasks.batchCreate
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.
Tạo và trả về một loạt đối tượng Task
mới.
Yêu cầu HTTP
POST https://fleetengine.googleapis.com/v1/{parent=providers/*}/tasks:batchCreate
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
parent |
string
Bắt buộc. Tài nguyên mẹ được tất cả tác vụ chia sẻ. Giá trị này phải ở định dạng providers/{provider} . provider phải là mã dự án trên Google Cloud. Ví dụ: sample-cloud-project . Trường mẹ trong thông báo CreateTaskRequest phải trống hoặc phải khớp với trường này.
|
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:
Trường |
header |
object (DeliveryRequestHeader )
Không bắt buộc. Tiêu đề yêu cầu API phân phối chuẩn. Lưu ý: Nếu bạn đặt trường này, thì trường tiêu đề trong thông báo CreateTaskRequest phải để trống hoặc phải khớp với trường này.
|
requests[] |
object (CreateTaskRequest )
Bắt buộc. Thông báo yêu cầu chỉ định các tài nguyên cần tạo. Lưu ý: Bạn có thể tạo tối đa 500 việc cần làm trong một lô.
|
Nội dung phản hồi
Thông báo phản hồi BatchCreateTask
.
Nếu thành công, phần nội dung phản hồi sẽ chứa dữ liệu có cấu trúc sau:
Biểu diễn dưới dạng JSON |
{
"tasks": [
{
object (Task )
}
]
} |
Trường |
tasks[] |
object (Task )
Các việc cần làm đã tạo.
|
CreateTaskRequest
Thông báo yêu cầu tasks.create
.
Biểu diễn dưới dạng JSON |
{
"header": {
object (DeliveryRequestHeader )
},
"parent": string,
"taskId": string,
"task": {
object (Task )
}
} |
Trường |
parent |
string
Bắt buộc. Phải ở định dạng providers/{provider} . provider phải là mã dự án trên Google Cloud. Ví dụ: sample-cloud-project .
|
taskId |
string
Bắt buộc. Mã công việc phải là mã duy nhất, nhưng không được là mã vận đơn. Để lưu trữ mã vận đơn, hãy sử dụng trường trackingId . Xin lưu ý rằng nhiều tác vụ có thể có cùng một trackingId . Mã công việc phải tuân theo các quy định hạn chế sau:
- Phải là một chuỗi Unicode hợp lệ.
- Giới hạn độ dài tối đa là 64 ký tự.
- Được chuẩn hoá theo Unicode Normalization Form C (Biểu mẫu chuẩn hoá Unicode C).
- Không được chứa bất kỳ ký tự ASCII nào sau đây: '/', ':', '?', ',' hoặc '#'.
|
task |
object (Task )
Bắt buộc. Thực thể Task (Việc cần làm) cần tạo. Khi tạo một Việc cần làm, bạn phải điền vào các trường sau:
type
state (phải được đặt thành OPEN )
trackingId (không được đặt cho các tác vụ UNAVAILABLE hoặc SCHEDULED_STOP , nhưng bắt buộc đối với tất cả các loại tác vụ khác)
plannedLocation (không bắt buộc đối với các tác vụ UNAVAILABLE )
taskDuration
Bạn có thể tuỳ ý đặt các trường sau:
targetTimeWindow
taskTrackingViewConfig
attributes
Lưu ý: Trường name của Task (Tác vụ) sẽ bị bỏ qua. Bạn không được đặt tất cả các trường Việc cần làm khác; nếu không, hệ thống sẽ trả về lỗi.
|
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\u003eCreates up to 500 \u003ccode\u003eTask\u003c/code\u003e objects at once using the \u003ccode\u003eBatchCreateTasks\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eRequires a \u003ccode\u003eparent\u003c/code\u003e resource in the URL path, indicating the Google Cloud Project ID.\u003c/p\u003e\n"],["\u003cp\u003eThe request body includes an optional \u003ccode\u003eheader\u003c/code\u003e and a required list of \u003ccode\u003erequests\u003c/code\u003e, each defining a \u003ccode\u003eTask\u003c/code\u003e to create.\u003c/p\u003e\n"],["\u003cp\u003eThe response returns a list of created \u003ccode\u003eTask\u003c/code\u003e objects within the \u003ccode\u003etasks\u003c/code\u003e field.\u003c/p\u003e\n"],["\u003cp\u003eEach individual \u003ccode\u003eCreateTaskRequest\u003c/code\u003e requires a \u003ccode\u003etaskId\u003c/code\u003e, \u003ccode\u003etype\u003c/code\u003e, \u003ccode\u003estate\u003c/code\u003e, \u003ccode\u003etrackingId\u003c/code\u003e, and other relevant fields depending on the task type.\u003c/p\u003e\n"]]],["This document details how to create a batch of `Task` objects via a `POST` HTTP request to `https://fleetengine.googleapis.com/v1/{parent=providers/*}/tasks:batchCreate`. The `parent` path parameter is required and specifies the provider. The request body should contain a `header` and an array of `requests`, where each request includes a `CreateTaskRequest`. Each `CreateTaskRequest` requires a `parent`, `taskId`, and a `task` entity with specific fields. The response body returns an array of the created `Task` objects.\n"],null,["# Method: providers.tasks.batchCreate\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 - [JSON representation](#body.BatchCreateTasksResponse.SCHEMA_REPRESENTATION)\n- [CreateTaskRequest](#CreateTaskRequest)\n - [JSON representation](#CreateTaskRequest.SCHEMA_REPRESENTATION)\n\nCreates and returns a batch of new `Task` objects.\n\n### HTTP request\n\n`POST https://fleetengine.googleapis.com/v1/{parent=providers/*}/tasks:batchCreate`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `parent` | `string` Required. The parent resource shared by all tasks. This value must be in the format `providers/{provider}`. The `provider` must be the Google Cloud Project ID. For example, `sample-cloud-project`. The parent field in the `CreateTaskRequest` messages must either be empty, or it must match this field. |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"header\": { object (/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/DeliveryRequestHeader) }, \"requests\": [ { object (/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks/batchCreate#CreateTaskRequest) } ] } ``` |\n\n| Fields ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `header` | `object (`[DeliveryRequestHeader](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/DeliveryRequestHeader)`)` Optional. The standard Delivery API request header. Note: If you set this field, then the header field in the `CreateTaskRequest` messages must either be empty, or it must match this field. |\n| `requests[]` | `object (`[CreateTaskRequest](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks/batchCreate#CreateTaskRequest)`)` Required. The request message that specifies the resources to create. Note: You can create a maximum of 500 tasks in a batch. |\n\n### Response body\n\nThe `BatchCreateTask` response message.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"tasks\": [ { object (/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks#Task) } ] } ``` |\n\n| Fields ||\n|-----------|--------------------------------------------------------------------------------------------------------------------------------|\n| `tasks[]` | `object (`[Task](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks#Task)`)` The created Tasks. |\n\nCreateTaskRequest\n-----------------\n\nThe `tasks.create` request message.\n\n| JSON representation |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"header\": { object (/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/DeliveryRequestHeader) }, \"parent\": string, \"taskId\": string, \"task\": { object (/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks#Task) } } ``` |\n\n| Fields ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `header` | `object (`[DeliveryRequestHeader](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/DeliveryRequestHeader)`)` Optional. The standard Delivery API request header. |\n| `parent` | `string` Required. Must be in the format `providers/{provider}`. The `provider` must be the Google Cloud Project ID. For example, `sample-cloud-project`. |\n| `taskId` | `string` Required. The Task ID must be unique, but it should be not a shipment tracking ID. To store a shipment tracking ID, use the `trackingId` field. Note that multiple tasks can have the same `trackingId`. Task IDs are subject to the following restrictions: - Must be a valid Unicode string. - Limited to a maximum length of 64 characters. - Normalized according to [Unicode Normalization Form C](http://www.unicode.org/reports/tr15/). - May not contain any of the following ASCII characters: '/', ':', '?', ',', or '#'. |\n| `task` | `object (`[Task](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks#Task)`)` Required. The Task entity to create. When creating a Task, the following fields are required: - `type` - `state` (must be set to `OPEN`) - `trackingId` (must not be set for `UNAVAILABLE` or `SCHEDULED_STOP` tasks, but required for all other task types) - `plannedLocation` (optional for `UNAVAILABLE` tasks) - `taskDuration` The following fields can be optionally set: - `targetTimeWindow` - `taskTrackingViewConfig` - `attributes` Note: The Task's `name` field is ignored. All other Task fields must not be set; otherwise, an error is returned. |"]]