Method: files.modifyLabels
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Modifica il set di etichette applicate a un file. Restituisce un elenco delle etichette aggiunte o modificate.
Richiesta HTTP
POST https://www.googleapis.com/drive/v2/files/{fileId}/modifyLabels
L'URL utilizza la sintassi di transcodifica gRPC.
Parametri del percorso
Parametri |
fileId |
string
L'ID del file a cui appartengono le etichette.
|
Corpo della richiesta
Il corpo della richiesta contiene un'istanza di ModifyLabelsRequest
.
Corpo della risposta
Risposta a una richiesta files.modifyLabels. Contiene solo le etichette aggiunte o aggiornate dalla richiesta.
In caso di esito positivo, il corpo della risposta contiene dati con la seguente struttura:
Rappresentazione JSON |
{
"modifiedLabels": [
{
object (Label )
}
],
"kind": string
} |
Campi |
modifiedLabels[] |
object (Label )
L'elenco delle etichette aggiunte o aggiornate dalla richiesta.
|
kind |
string
Questo valore è sempre drive#modifyLabelsResponse
|
Ambiti di autorizzazione
Richiede uno dei seguenti ambiti OAuth:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
Alcuni ambiti sono soggetti a restrizioni e richiedono una valutazione della sicurezza per poter essere utilizzati dalla tua app. Per ulteriori informazioni, consulta la Guida all'autorizzazione.
ModifyLabelsRequest
Una richiesta di modifica dell'insieme di etichette di un file. Questa richiesta potrebbe contenere molte modifiche che avranno esito positivo o negativo in modo atomico.
Rappresentazione JSON |
{
"labelModifications": [
{
object (LabelModification )
}
],
"kind": string
} |
Campi |
labelModifications[] |
object (LabelModification )
L'elenco delle modifiche da applicare alle etichette del file.
|
kind |
string
Questo valore è sempre drive#modifyLabelsRequest .
|
LabelModification
Modifica di un'etichetta su un file. Un oggetto LabelModification può essere utilizzato per applicare un'etichetta a un file, aggiornare un'etichetta esistente su un file o rimuovere un'etichetta da un file.
Rappresentazione JSON |
{
"fieldModifications": [
{
object (FieldModification )
}
],
"labelId": string,
"removeLabel": boolean,
"kind": string
} |
Campi |
fieldModifications[] |
object (FieldModification )
L'elenco delle modifiche ai campi di questa etichetta.
|
labelId |
string
L'ID dell'etichetta da modificare.
|
removeLabel |
boolean
Se true, l'etichetta verrà rimossa dal file.
|
kind |
string
Questo valore è sempre drive#labelModification .
|
FieldModification
Modifica di un campo di un'etichetta.
Rappresentazione JSON |
{
"setDateValues": [
string
],
"setTextValues": [
string
],
"setSelectionValues": [
string
],
"setIntegerValues": [
string
],
"setUserValues": [
string
],
"fieldId": string,
"kind": string,
"unsetValues": boolean
} |
Campi |
setDateValues[] |
string
Sostituisce il valore di un campo date con questi nuovi valori. La stringa deve essere nel formato di data completa RFC 3339: AAAA-MM-GG.
|
setTextValues[] |
string
Imposta il valore di un campo text .
|
setSelectionValues[] |
string
Sostituisce un campo selection con questi nuovi valori.
|
setIntegerValues[] |
string (int64 format)
Sostituisce il valore di un campo integer con questi nuovi valori.
|
setUserValues[] |
string
Sostituisce un campo user con questi nuovi valori. I valori devono essere indirizzi email validi.
|
fieldId |
string
L'ID del campo da modificare.
|
kind |
string
Questo valore è sempre drive#labelFieldModification .
|
unsetValues |
boolean
Annulla i valori per questo campo.
|
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-25 UTC.
[null,null,["Ultimo aggiornamento 2025-07-25 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/v2/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/v2/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/v2/Label) } ], \"kind\": string } ``` |\n\n| Fields ||\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `modifiedLabels[]` | `object (`[Label](/workspace/drive/api/reference/rest/v2/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/v2/files/modifyLabels#LabelModification) } ], \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `labelModifications[]` | `object (`[LabelModification](/workspace/drive/api/reference/rest/v2/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/v2/files/modifyLabels#FieldModification) } ], \"labelId\": string, \"removeLabel\": boolean, \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fieldModifications[]` | `object (`[FieldModification](/workspace/drive/api/reference/rest/v2/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. |"]]