Properties: delete

Stay organized with collections Save and categorize content based on your preferences.

Deletes a property. Try it now or see an example.

Request

HTTP request

DELETE https://www.googleapis.com/drive/v2/files/fileId/properties/propertyKey

Parameters

Parameter name Value Description
Path parameters
fileId string The ID of the file.
propertyKey string The key of the property.
Optional query parameters
visibility string The visibility of the property.

Authorization

This request requires authorization with at least one of the following scopes:

Scope
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.metadata

Some scopes are restricted and require a security assessment for your app to use them. For more information, see the authentication and authorization page.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns an empty response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

import com.google.api.services.drive.Drive;
import com.google.api.services.drive.Drive.Properties.Delete;
import com.google.api.services.drive.model.Property;

import java.io.IOException;
// ...

public class MyClass {

  // ...

  /**
   * Remove a custom property.
   *
   * @param service Drive API service instance.
   * @param fileId ID of the file to remove the property for.
   * @param key ID of the property to remove.
   * @param visibility The type of property ('PUBLIC' or 'PRIVATE').
   */
  private static void removeProperty(Drive service, String fileId, String key, String visibility) {
    try {
      Delete request = service.properties().delete(fileId, key);
      request.setVisibility(visibility);
      request.execute();
    } catch (IOException e) {
      System.out.println("An error occurred: " + e);
    }
  }

  // ...

}

.NET

Uses the .NET client library.

using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;

using System.Net;
// ...

public class MyClass {

  // ...

  /// <summary>
  /// Remove a custom property.
  /// </summary>
  /// <param name="service">Drive API service instance.</param>
  /// <param name="fileId">ID of the file to remove the property for.</param>
  /// <param name="key">ID of the property to remove.</param>
  /// <param name="visibility">The type of property ('PUBLIC' or 'PRIVATE').</param>
  public static void RemoveProperty(DriveService service, String fileId,
      String key, PropertiesResource.Visibility visibility) {
    try {
      PropertiesResource.DeleteRequest request =
          service.Properties.Delete(fileId, key);
      request.Visibility = visibility;
      request.Execute();
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
  }

  // ...

}

PHP

Uses the PHP client library.

/**
 * Remove a custom property.
 *
 * @param Google_Service_Drive $service Drive API service instance.
 * @param String $fileId ID of the file to remove the property for.
 * @param String $key ID of the property to remove.
 * @param String $visibility The type of property ('PUBLIC' or 'PRIVATE').
 */
function removeProperty($service, $fileId, $key, $visibility) {
  try {
    $optParams = array('visibility' => $visibility);
    $service->properties->delete($fileId, $key, $optParams);
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
}

Python

Uses the Python client library.

def delete_property(service, file_id, key, visibility):
  """Remove a custom property.

  Args:
    service: Drive API service instance.
    file_id: ID of the file to remove the property for.
    key: ID of the property to remove.
    visibility: type of property ('PUBLIC' or 'PRIVATE').
  """
  try:
    service.properties().delete(
        fileId=file_id, propertyKey=key, visibility=visibility).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

JavaScript

Uses the JavaScript client library.

/**
 * Remove a custom property.
 *
 * @param {String} fileId ID of the file to remove the property for.
 * @param {String} key ID of the property to remove.
 * @param {String} visibility The type of property ('PUBLIC' or 'PRIVATE').
 */
function removeProperty(fileId, key, visibility) {
  var request = gapi.client.drive.properties.delete({
    'fileId': fileId,
    'propertyKey': key,
    'visibility': visibility
  });
  request.execute(function(resp) { });
}

Try it!

Use the APIs Explorer below to call this method on live data and see the response.