PHP Google Drive API Search Issues with Image Metadata

I’m having trouble with search queries in the Google Drive API using PHP. When I try to search using photoMetadata fields, I keep getting errors.

Working Query:

$searchQuery = "mimeType='image/jpeg'";
$response = $driveService->files->listFiles([
    'q' => $searchQuery,
    'fields' => 'files(id, name, mimeType)'
]);

Failing Query:

$searchQuery = "photoMetadata.width > 1000";
$response = $driveService->files->listFiles([
    'q' => $searchQuery,
    'fields' => 'files(id, name, photoMetadata)'
]);

I’ve tried different approaches like using photoMetadata has {key='width', value='1200'} and accessing nested properties with dot notation, but nothing works. I have all the required scopes enabled.

What I’m trying to achieve is getting images where photoMetadata.timestamp > userTime. The basic MIME type searches work fine, but any query involving image metadata properties fails.

Has anyone successfully searched using image metadata fields? Am I missing something in the query syntax?

i feel ya, man. it really sucks that the API doesn’t support direct searches like that for metadata. ur best bet is to fetch the files and filter them in ur code later. hopefully they’ll fix this soon!

Yeah, Google Drive API doesn’t let you search by photoMetadata fields directly - it’s a frustrating limitation that trips up tons of developers. You can only get width, height, timestamp, etc. in the response, not use them to filter results. Your syntax looks right, but the API just won’t accept it. The workaround? Pull all image files with your mimeType query first, then filter them client-side based on the photoMetadata you need. Not great for performance with big datasets, but it’s the only way to do it right now.