List folders which has not a custom property in Google Drive API v3 and .NET

本秂侑毒 提交于 2021-01-29 17:44:04

问题


I want to list all those items that has no imdb property key or if its value is null/empty. I tried wtih (I'm using Google Drive API for .NET) :

var request = PrepareListRequest(itemsPerPage, nextPageToken);
request.Q = $"'{id}' in parents and not properties has (imdb) or properties(imdb) is null"; // don't know here.

And the method:

private FilesResource.ListRequest PrepareListRequest(int itemsPerPage, string nextPageToken)
{
  var request = dataService.Files.List();
  request.PageSize = itemsPerPage;
  request.SupportsAllDrives = true;
  request.IncludeItemsFromAllDrives = true;

  if (!string.IsNullOrWhiteSpace(nextPageToken))
  {
    request.PageToken = nextPageToken;
  }

  request.Fields = "nextPageToken, files";
  return request;
}

But I got 400 error:

Update 1: I tried also

  request.Q = $"'{id}' in parents and not properties has {{ key='imdb' }}";

Got same error.

Update 2: I tried:

 request.Q = $"'{id}' in parents (and properties has {{ key='imdb' and value=null) }} or not properties has {{ key='imdb' and value='' }})";

I want to get files/folders which don't have imdb in properties list.

How to achieve this ?


回答1:


I found solution, if want to display items which don't have xxx in properties:

request.Q = $"'{id}' in parents and (properties has {{ key='xxx' and value='' }} or not properties has {{ key='xxx' and value='' }})";


来源:https://stackoverflow.com/questions/63559883/list-folders-which-has-not-a-custom-property-in-google-drive-api-v3-and-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!