1

Is there any way in which I can get all the versions of all OneDrive items in my Drive using Graph API. And I want a single query to complete this work.

DriveItemVersion resource type doesn't seem to support this (https://learn.microsoft.com/en-us/graph/api/resources/driveitemversion?view=graph-rest-1.0). It looks like we need a separate query to get versions of each OneDrive item. This is not a very efficient way.

Let me know if there is any workaround/fix for this problem.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
user13260866
  • 131
  • 1
  • 2
  • 9

1 Answers1

1

This isn't possible and would be extremely inefficient. Just as an example, I have ~100k DriveItems in my OneDrive. Attempting to retrieve all of the items, and each version would take an exceedingly long time.

It is far more efficient to retrieve the minimum DriveItem properties you need using a Delta query. You can then process individual DriveItems in batches. Once complete you can then retrieve another Delta and processes any files that have changed in the meantime.

I would also suggest taking another look at your requirements. There are very few scenarios where it makes sense to query every file in a Drive. You shouldn't attempt to apply the same patterns used for local/networked storage to cloud storage solutions (be it OneDrive, Google Drive, DropBox, etc.). They are much more akin to a database of binaries than a file system.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
  • Thanks. Though it will be a time and bandwidth-consuming operation there are few use cases where it's unavoidable. E.g. I want to download all the items in my OneDrive (along with their versions to save multiple queries). Or another scenario would be I want to download only changed versions using delta query. But it looks like both these operations are not really possible using existing Graph APIs. – user13260866 Jun 05 '21 at 11:52