Method: files.modifyLabels
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Ändert die Gruppe von Labels, die auf eine Datei angewendet werden. Weitere Informationen finden Sie unter Label-Feld für eine Datei festlegen.
Gibt eine Liste der Labels zurück, die hinzugefügt oder geändert wurden.
HTTP-Anfrage
POST https://www.googleapis.com/drive/v3/files/{fileId}/modifyLabels
Die URL verwendet die Syntax der gRPC-Transcodierung.
Pfadparameter
Parameter |
fileId |
string
Die ID der Datei, zu der die Labels gehören.
|
Anfragetext
Der Anfragetext enthält eine Instanz von ModifyLabelsRequest
.
Antworttext
Antwort auf eine files.modifyLabels
-Anfrage. Dieser enthält nur die Labels, die durch die Anfrage hinzugefügt oder aktualisiert wurden.
Wenn der Vorgang erfolgreich abgeschlossen wurde, enthält der Antworttext Daten mit der folgenden Struktur:
JSON-Darstellung |
{
"modifiedLabels": [
{
object (Label )
}
],
"kind": string
} |
Felder |
modifiedLabels[] |
object (Label )
Die Liste der Labels, die durch die Anfrage hinzugefügt oder aktualisiert wurden.
|
kind |
string
Dies ist immer "drive#modifyLabelsResponse" .
|
Autorisierungsbereiche
Erfordert einen der folgenden OAuth-Bereiche:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
Einige Bereiche sind eingeschränkt und erfordern eine Sicherheitsprüfung für Ihre App, damit sie verwendet werden können. Weitere Informationen finden Sie im Autorisierungsleitfaden.
ModifyLabelsRequest
Ein Request zum Ändern der Labels für eine Datei. Diese Anfrage kann viele Änderungen enthalten, die entweder alle erfolgreich sind oder alle atomar fehlschlagen.
JSON-Darstellung |
{
"labelModifications": [
{
object (LabelModification )
}
],
"kind": string
} |
Felder |
labelModifications[] |
object (LabelModification )
Die Liste der Änderungen, die auf die Labels in der Datei angewendet werden sollen.
|
kind |
string
Dies ist immer "drive#modifyLabelsRequest" .
|
LabelModification
Eine Änderung an einem Label für eine Datei. Mit einem LabelModification
können Sie ein Label auf eine Datei anwenden, ein vorhandenes Label für eine Datei aktualisieren oder ein Label aus einer Datei entfernen.
JSON-Darstellung |
{
"fieldModifications": [
{
object (FieldModification )
}
],
"labelId": string,
"removeLabel": boolean,
"kind": string
} |
Felder |
fieldModifications[] |
object (FieldModification )
Die Liste der Änderungen an den Feldern dieses Labels.
|
labelId |
string
Die ID des zu ändernden Labels.
|
removeLabel |
boolean
Bei „true“ wird das Label aus der Datei entfernt.
|
kind |
string
Dies ist immer "drive#labelModification" .
|
FieldModification
Eine Änderung an einem Feld eines Labels.
JSON-Darstellung |
{
"setDateValues": [
string
],
"setTextValues": [
string
],
"setSelectionValues": [
string
],
"setIntegerValues": [
string
],
"setUserValues": [
string
],
"fieldId": string,
"kind": string,
"unsetValues": boolean
} |
Felder |
setDateValues[] |
string
Ersetzt den Wert eines date -Felds durch diese neuen Werte. Der String muss im RFC 3339-Format für vollständige Datumsangaben angegeben werden: JJJJ-MM-TT.
|
setTextValues[] |
string
Legt den Wert eines text -Felds fest.
|
setSelectionValues[] |
string
Ersetzt ein selection -Feld durch diese neuen Werte.
|
setIntegerValues[] |
string (int64 format)
Ersetzt den Wert eines integer -Felds durch diese neuen Werte.
|
setUserValues[] |
string
Ersetzt ein user -Feld durch diese neuen Werte. Die Werte müssen gültige E-Mail-Adressen sein.
|
fieldId |
string
Die ID des zu ändernden Felds.
|
kind |
string
Dies ist immer "drive#labelFieldModification" .
|
unsetValues |
boolean
Entfernt die Werte für dieses Feld.
|
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-27 (UTC).
[null,null,["Zuletzt aktualisiert: 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. |"]]