Method: files.modifyLabels
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Requête HTTP
POST https://www.googleapis.com/drive/v3/files/{fileId}/modifyLabels
L'URL utilise la syntaxe de transcodage gRPC.
Paramètres de chemin d'accès
Paramètres |
fileId |
string
ID du fichier auquel appartiennent les libellés.
|
Corps de la requête
Le corps de la requête contient une instance de ModifyLabelsRequest
.
Corps de la réponse
Réponse à une requête files.modifyLabels
. Il ne contient que les libellés ajoutés ou modifiés par la requête.
Si la requête aboutit, le corps de la réponse contient des données qui ont la structure suivante :
Représentation JSON |
{
"modifiedLabels": [
{
object (Label )
}
],
"kind": string
} |
Champs |
modifiedLabels[] |
object (Label )
Liste des libellés ajoutés ou modifiés par la requête.
|
kind |
string
Cette valeur est toujours "drive#modifyLabelsResponse" .
|
Niveaux d'accès des autorisations
Nécessite l'un des champs d'application OAuth suivants :
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
Certains sont soumis à des restrictions et nécessitent une évaluation de sécurité pour que votre application puisse les utiliser. Pour en savoir plus, consultez le guide d'autorisation.
ModifyLabelsRequest
Requête permettant de modifier l'ensemble des libellés d'un fichier. Cette requête peut contenir de nombreuses modifications qui réussiront ou échoueront toutes de manière atomique.
Représentation JSON |
{
"labelModifications": [
{
object (LabelModification )
}
],
"kind": string
} |
Champs |
labelModifications[] |
object (LabelModification )
Liste des modifications à appliquer aux libellés du fichier.
|
kind |
string
Cette valeur est toujours "drive#modifyLabelsRequest" .
|
LabelModification
Modification d'un libellé sur un fichier. Un LabelModification
peut être utilisé pour appliquer un libellé à un fichier, mettre à jour un libellé existant sur un fichier ou supprimer un libellé d'un fichier.
Représentation JSON |
{
"fieldModifications": [
{
object (FieldModification )
}
],
"labelId": string,
"removeLabel": boolean,
"kind": string
} |
Champs |
fieldModifications[] |
object (FieldModification )
Liste des modifications apportées aux champs de ce libellé.
|
labelId |
string
ID du libellé à modifier.
|
removeLabel |
boolean
Si la valeur est "vrai", le libellé sera supprimé du fichier.
|
kind |
string
Cette valeur est toujours "drive#labelModification" .
|
FieldModification
Modification d'un champ de libellé.
Représentation JSON |
{
"setDateValues": [
string
],
"setTextValues": [
string
],
"setSelectionValues": [
string
],
"setIntegerValues": [
string
],
"setUserValues": [
string
],
"fieldId": string,
"kind": string,
"unsetValues": boolean
} |
Champs |
setDateValues[] |
string
Remplace la valeur d'un champ date par ces nouvelles valeurs. La chaîne doit être au format date complète RFC 3339 : AAAA-MM-JJ.
|
setTextValues[] |
string
Définit la valeur d'un champ text .
|
setSelectionValues[] |
string
Remplace un champ selection par ces nouvelles valeurs.
|
setIntegerValues[] |
string (int64 format)
Remplace la valeur d'un champ integer par ces nouvelles valeurs.
|
setUserValues[] |
string
Remplace un champ user par ces nouvelles valeurs. Les valeurs doivent être des adresses e-mail valides.
|
fieldId |
string
ID du champ à modifier.
|
kind |
string
Cette valeur est toujours "drive#labelFieldModification" .
|
unsetValues |
boolean
Supprime les valeurs de ce champ.
|
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/27 (UTC).
[null,null,["Dernière mise à jour le 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. |"]]