Lists a file's properties. Try it now or see an example.
Request
HTTP request
GET https://www.googleapis.com/drive/v2/files/fileId/properties
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
fileId |
string |
The ID of the file. |
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.readonly |
https://www.googleapis.com/auth/drive.metadata.readonly |
https://www.googleapis.com/auth/drive.appdata |
https://www.googleapis.com/auth/drive.metadata |
https://www.googleapis.com/auth/drive.photos.readonly |
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 a response body with the following structure:
{ "kind": "drive#propertyList", "etag": etag, "selfLink": string, "items": [ properties Resource ] }
Property name | Value | Description | Notes |
---|---|---|---|
kind |
string |
This is always drive#propertyList. | |
etag |
etag |
The ETag of the list. | |
selfLink |
string |
The link back to this list. | |
items[] |
list |
The list of properties. |
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.model.Property; import com.google.api.services.drive.model.PropertyList; import java.io.IOException; import java.util.List; // ... public class MyClass { // ... /** * Retrieve a list of custom file properties. * * @param service Drive API service instance. * @param fileId ID of the file to retrieve properties for. * @return List of custom properties. */ private static List<Property> retrieveProperties(Drive service, String fileId) { try { PropertyList properties = service.properties().list(fileId).execute(); return properties.getItems(); } catch (IOException e) { System.out.println("An error occurred: " + e); } return null; } // ... }
.NET
Uses the .NET client library.
using Google.Apis.Drive.v2; using Google.Apis.Drive.v2.Data; using System.Collections.Generic; // ... public class MyClass { // ... /// <summary> /// Retrieve a list of custom file properties. /// </summary> /// <param name="service">Drive API service instance.</param> /// <param name="fileId">ID of the file to retrieve properties for.</param> /// <returns>List of custom properties.</returns> public static IList<Property> RetrieveProperties(DriveService service, String fileId) { try { PropertyList properties = service.Properties.List(fileId).Execute(); return properties.Items; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } return null; } // ... }
PHP
Uses the PHP client library.
/** * Retrieve a list of custom file properties. * * @param Google_Service_Drive $service Drive API service instance. * @param String $fileId ID of the file to retrieve properties for. * @return Array List of custom properties. */ function retrieveProperties($service, $fileId) { try { $properties = $service->properties->listProperties($fileId); return $properties->getItems(); } catch (Exception $e) { print "An error occurred: " . $e->getMessage(); } return NULL; }
Python
Uses the Python client library.
def retrieve_properties(service, file_id): """Retrieve a list of custom file properties. Args: service: Drive API service instance. file_id: ID of the file to retrieve properties for. Returns: List of custom properties. """ try: props = service.properties().list(fileId=file_id).execute() return props.get('items', []) except errors.HttpError, error: print 'An error occurred: %s' % error return None
JavaScript
Uses the JavaScript client library.
/** * Retrieve a list of custom file properties. * * @param {String} fileId ID of the file to retrieve properties for. * @param {Function} callback Function to call when the request is complete. */ function retrieveProperties(fileId, callback) { var request = gapi.client.drive.properties.list({ 'fileId': fileId }); request.execute(function(resp) { callback(resp.items); }); }
Try it!
Use the APIs Explorer below to call this method on live data and see the response.