Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

680
Views
How to list all root folder and shares on the Google Drive API v3 while paging and using order by?

I've seen a few questions about this but none cover my scenario.

Basically what I want is to use tokens to do paging and also list all folders and files in the root folder including shared files and folders.

This appears to be working, but once I add orderBy it doesn't work well. It works ok with sorting if I remove or sharedWithMe = true but once I add it it like the shared items aren't sorted.

What am I doing wrong?

This is my code (Kotlin and on Android):

val response =
 gDriveClient.files()
 .list()
 .setSpaces("drive")
 .setCorpora("user")
 .setFields("files(id, name, size, modifiedTime, mimeType, parents, quotaBytesUsed),nextPageToken")
 .setQ("('root' in parents or sharedWithMe = true) and trashed = false")
 .setOrderBy("folder,name")
 .setPageSize(params.loadSize)
 .setPageToken(token)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Unfortunately, the behaviour you are experiencing seems to be a bug as your query and request is formatted correctly and necessary to obtain exactly what you were looking for. I have reported this behaviour here : https://issuetracker.google.com/issues/174476354 . Please consider starring the report to indicate that this is also affecting you.

Workaround

A possible workaround to this would be to order and filter your response after the request has been executed which unfortunately will not let you perform the request with pagination for your specific purpose (as for ordering everything you would need all the files).

References

  • Drive.Files.list()

  • Query parameter sharedWithMe

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!