How to get list of files by folder on Google Drive API

I am trying to build a web UI for users to navigate his/her Google Drive and select one or more documents to be referenced later on in a website from a DB. I am currently building a web interface using .NET. The problem I am facing is that I can not find a single function to get a list of files by folder Id. I tried using:

...www.googleapis.com/drive/v2/files/BB0CHANGEDIDF5waGdzbUQ5aWs/children

…but that will only give the files reference ID of the files within the folder (the so called children resource item), which means I have to loop through those files and create a call for each one of them in order to get all the metadata I need for my UI. Unfortunately..

...www.googleapis.com/drive/v2/files

..will list ALL my files with no filtering options by folder. I would like to know if there is an efficient way of extracting a folder& file list from a single call to the Drive server by for a specific folder.

I also tried this (based on answer to the similar issue): I am using Fiddler to do direct calls to the api. When I use this to make the call `

...www.googleapis.com/drive/v2/files?q='BB0CHANGEDIDF5waGdzbUQ5aWs'

I get an error:

{
 "error": {
  "errors": [
   {wrongID
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value",
    "locationType": "parameter",
    "location": "q"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

Even using google's test page does not do it. It looks like the "files" endpoint does not accept any parameter.

There has to be a way to achieve this!

Thank you for your help

You should be able to simply use files/list with a parent query;

GET https://www.googleapis.com/drive/v2/files?q='BB0CHANGEDIDF5waGdzbUQ5aWs'+in+parents&key={YOUR_API_KEY}

Files: list | Google Drive API, You should be able to simply use files/list with a parent query; GET� Parameter name Value Description; Optional query parameters: corpora: string: Groupings of files to which the query applies. Supported groupings are: 'user' (files created by, opened by, or shared directly with the user), 'drive' (files in the specified shared drive as indicated by the 'driveId'), 'domain' (files shared to the user's domain), and 'allDrives' (A combination of 'user' and 'drive

Here's how to get specific fields of files in a folder using v3 API:

https://www.googleapis.com/drive/v3/files?q="folderId"+in+parents&fields=files(md5Checksum,+originalFilename)
//

Replace "folderId" with the folder ID.

You can use &fields=files(*) to get all of the file's fields.

Search for files and folders | Google Drive API, cool I found the answer. $optParams = array( 'pageSize' => 10, 'fields' => " nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size � The ID of the folder. To list all files in the root folder, use the alias root as the value for folderId. Optional query parameters: maxResults: integer: Maximum number of children to return. Acceptable values are 0 to 1000, inclusive. (Default: 100) orderBy: string: A comma-separated list of sort keys.

If you're doing this on javascript with v3, try this on the request body:

{
  q: `'${folderId}' in parents`
}

However, this could also list the files from this folder that were deleted and are in the bin.So, you can do it like this:

{
  q: `'${folderId}' in parents and trashed = false`
}

How to get list of files by folder on Google Drive API, This article explains how to access Google Drive files through Google Drive API v3 and using OAuth2. The interface assets introduced I would like to know if there is an efficient way of extracting a folder& file list from a single call to the Drive server by for a specific folder. I also tried this ( based on answer to the similar issue ): I am using Fiddler to do direct calls to the api.

How to list files in a specific folder in Google Drive API v3 PHP , Create a project using the Google/Cloud Developers Console; Obtain & use OAuth2 G Suite APIs; Obtain file and folder information with the Google Drive API� 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.

List and display items stored in a Google Drive folder using the , The examples on Google Drive API website show that this method should be used: [GTLRDriveQuery� If not specified, the response includes a default set of fields specific to this method. For development you can use the special value * to return all fields, but you'll achieve greater performance by only selecting the fields you need. For more information, see Return specific fields for a file. includePermissionsForView: string

Display the first 100 files & folders in your Google Drive, I am using https://developers.google.com/drive/api/v3/ API to get list of folder and files I don't want child folder and files as a parent folder/file. To delete your Google Drive files, move them to the trash. You can also restore your files or empty the trash to permanently delete them. If you delete, restore, or permanently delete multiple files or folders at once, it might take time for you to notice the changes. Move a file to the trash. To remove a file from your Drive, put it in your trash.

Comments
  • See stackoverflow.com/questions/41741520/…
  • Yes, there API docs are horrible :(
  • THANK YOU for your URL request string sample. The problem was that I was missing the: +in+parents Can you tell me where this "in parents" add is documented? I completely missed it.
  • @user3199365 It's documented here, just search the page for "parents".
  • q='root' in parents will get you the top level folder, in case you were wondering
  • any documentation to api v3 please ?
  • not work for me using version v3