Method: files.modifyLabels
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คำขอ HTTP
POST https://www.googleapis.com/drive/v3/files/{fileId}/modifyLabels
URL ใช้ไวยากรณ์การแปลงรหัส gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
fileId |
string
รหัสของไฟล์ที่มีป้ายกำกับ
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ ModifyLabelsRequest
เนื้อหาการตอบกลับ
การตอบกลับคำขอ files.modifyLabels
ซึ่งมีเฉพาะป้ายกำกับที่คำขอเพิ่มหรืออัปเดต
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีข้อมูลซึ่งมีโครงสร้างดังต่อไปนี้
การแสดง JSON |
{
"modifiedLabels": [
{
object (Label )
}
],
"kind": string
} |
ช่อง |
modifiedLabels[] |
object (Label )
รายการป้ายกำกับที่คำขอเพิ่มหรืออัปเดต
|
kind |
string
ซึ่งจะ"drive#modifyLabelsResponse" เสมอ
|
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth อย่างใดอย่างหนึ่งต่อไปนี้
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
ขอบเขตบางอย่างถูกจำกัดและต้องมีการประเมินความปลอดภัยเพื่อให้แอปของคุณใช้ขอบเขตเหล่านั้นได้ ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
ModifyLabelsRequest
คำขอแก้ไขชุดป้ายกำกับในไฟล์ คำขอนี้อาจมีการแก้ไขหลายรายการซึ่งจะสำเร็จทั้งหมดหรือล้มเหลวทั้งหมดในคราวเดียว
การแสดง JSON |
{
"labelModifications": [
{
object (LabelModification )
}
],
"kind": string
} |
ช่อง |
labelModifications[] |
object (LabelModification )
รายการการแก้ไขที่จะใช้กับป้ายกำกับในไฟล์
|
kind |
string
ซึ่งจะ"drive#modifyLabelsRequest" เสมอ
|
LabelModification
การแก้ไขป้ายกำกับในไฟล์ LabelModification
ใช้เพื่อติดป้ายกำกับให้กับไฟล์ อัปเดตป้ายกำกับที่มีอยู่บนไฟล์ หรือนำป้ายกำกับออกจากไฟล์ได้
การแสดง JSON |
{
"fieldModifications": [
{
object (FieldModification )
}
],
"labelId": string,
"removeLabel": boolean,
"kind": string
} |
ช่อง |
fieldModifications[] |
object (FieldModification )
รายการการแก้ไขช่องของป้ายกำกับนี้
|
labelId |
string
รหัสของป้ายกำกับที่จะแก้ไข
|
removeLabel |
boolean
หากเป็นจริง ระบบจะนำป้ายกำกับออกจากไฟล์
|
kind |
string
ซึ่งจะ"drive#labelModification" เสมอ
|
FieldModification
การแก้ไขฟิลด์ของป้ายกำกับ
การแสดง JSON |
{
"setDateValues": [
string
],
"setTextValues": [
string
],
"setSelectionValues": [
string
],
"setIntegerValues": [
string
],
"setUserValues": [
string
],
"fieldId": string,
"kind": string,
"unsetValues": boolean
} |
ช่อง |
setDateValues[] |
string
แทนที่ค่าของฟิลด์ date ด้วยค่าใหม่เหล่านี้ สตริงต้องอยู่ในรูปแบบวันที่แบบเต็ม RFC 3339 ซึ่งคือ YYYY-MM-DD
|
setTextValues[] |
string
ตั้งค่าของฟิลด์ text
|
setSelectionValues[] |
string
แทนที่selection ฟิลด์ด้วยค่าใหม่เหล่านี้
|
setIntegerValues[] |
string (int64 format)
แทนที่ค่าของinteger ฟิลด์ด้วยค่าใหม่เหล่านี้
|
setUserValues[] |
string
แทนที่user ฟิลด์ด้วยค่าใหม่เหล่านี้ ค่าต้องเป็นอีเมลที่ถูกต้อง
|
fieldId |
string
รหัสของฟิลด์ที่จะแก้ไข
|
kind |
string
ซึ่งจะ"drive#labelFieldModification" เสมอ
|
unsetValues |
boolean
ยกเลิกการตั้งค่าสำหรับช่องนี้
|
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 UTC
[null,null,["อัปเดตล่าสุด 2025-08-27 UTC"],[],[],null,["# Method: files.modifyLabels\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ModifyLabelsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [ModifyLabelsRequest](#ModifyLabelsRequest)\n - [JSON representation](#ModifyLabelsRequest.SCHEMA_REPRESENTATION)\n- [LabelModification](#LabelModification)\n - [JSON representation](#LabelModification.SCHEMA_REPRESENTATION)\n- [FieldModification](#FieldModification)\n - [JSON representation](#FieldModification.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nModifies the set of labels applied to a file. Returns a list of the labels that were added or modified.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v3/files/{fileId}/modifyLabels`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|---------------------------------------------------------|\n| `fileId` | `string` The ID of the file to which the labels belong. |\n\n### Request body\n\nThe request body contains an instance of [ModifyLabelsRequest](/workspace/drive/api/reference/rest/v3/files/modifyLabels#ModifyLabelsRequest).\n\n### Response body\n\nResponse to a files.modifyLabels request. This contains only those labels which were added or updated by the request.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------|\n| ``` { \"modifiedLabels\": [ { object (/workspace/drive/api/reference/rest/v3/Label) } ], \"kind\": string } ``` |\n\n| Fields ||\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `modifiedLabels[]` | `object (`[Label](/workspace/drive/api/reference/rest/v3/Label)`)` The list of labels which were added or updated by the request. |\n| `kind` | `string` This is always drive#modifyLabelsResponse |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/drive`\n- `\n https://www.googleapis.com/auth/drive.file`\n- `\n https://www.googleapis.com/auth/drive.metadata`\n\nSome scopes are restricted and require a security assessment for your app to use them. For more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent).\n\nModifyLabelsRequest\n-------------------\n\nA request to modify the set of labels on a file. This request may contain many modifications that will either all succeed or all fail atomically.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"labelModifications\": [ { object (/workspace/drive/api/reference/rest/v3/files/modifyLabels#LabelModification) } ], \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `labelModifications[]` | `object (`[LabelModification](/workspace/drive/api/reference/rest/v3/files/modifyLabels#LabelModification)`)` The list of modifications to apply to the labels on the file. |\n| `kind` | `string` This is always drive#modifyLabelsRequest. |\n\nLabelModification\n-----------------\n\nA modification to a label on a file. A LabelModification can be used to apply a label to a file, update an existing label on a file, or remove a label from a file.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"fieldModifications\": [ { object (/workspace/drive/api/reference/rest/v3/files/modifyLabels#FieldModification) } ], \"labelId\": string, \"removeLabel\": boolean, \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fieldModifications[]` | `object (`[FieldModification](/workspace/drive/api/reference/rest/v3/files/modifyLabels#FieldModification)`)` The list of modifications to this label's fields. |\n| `labelId` | `string` The ID of the label to modify. |\n| `removeLabel` | `boolean` If true, the label will be removed from the file. |\n| `kind` | `string` This is always drive#labelModification. |\n\nFieldModification\n-----------------\n\nA modification to a label's field.\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"setDateValues\": [ string ], \"setTextValues\": [ string ], \"setSelectionValues\": [ string ], \"setIntegerValues\": [ string ], \"setUserValues\": [ string ], \"fieldId\": string, \"kind\": string, \"unsetValues\": boolean } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `setDateValues[]` | `string` Replaces the value of a `date` field with these new values. The string must be in the RFC 3339 full-date format: YYYY-MM-DD. |\n| `setTextValues[]` | `string` Sets the value of a `text` field. |\n| `setSelectionValues[]` | `string` Replaces a `selection` field with these new values. |\n| `setIntegerValues[]` | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` Replaces the value of an `integer` field with these new values. |\n| `setUserValues[]` | `string` Replaces a `user` field with these new values. The values must be valid email addresses. |\n| `fieldId` | `string` The ID of the field to be modified. |\n| `kind` | `string` This is always drive#labelFieldModification. |\n| `unsetValues` | `boolean` Unsets the values for this field. |"]]