Documentation clarification for using DriveItem delta endpoint to download SharePoint Document library files

Ralph 10 Reputation points
2025-06-05T14:40:52.2766667+00:00

Attempting to download all files from a SharePoint Document library and then perform daily delta downloads for synchronization. This is being implemented in C# using the Microsoft Graph SDK.

The approach involves using the Delta endpoints of the Microsoft Graph, specifically the DriveItem delta endpoint.

Questions

Seeking clarification on the results from the API calls and the documentation.

  1. There are multiple identical results returned. The remarks documentation section mentions that The same item may appear more than once in a delta feed, for various reasons. You should use the last occurrence you see. Does this imply that a C# linq Last operation should be performed based on the Id field? If there are four identical items (IDs), should only the last instance be processed?
  2. When setting the page size (top) to 2, sometimes 4 results are returned. What might be causing this? Is it related to the folder structure within the document library?
  3. The root drive item appears in every page response. Is this behavior related to Replays?
  4. The goal is to download only files and not the folder structure. Is it appropriate to filter items with Where(x => x.File != null)?
    If a folder is deleted, will a delete object be returned for all the files within that folder?

What I did

  1. I wrote a [sample project]([https://github.com/LockTar/azure-storage-blob-manager-sample](https://github.com/%5BLockTar/azure-storage-blob-manager-sample%5D(https://github.com/LockTar/azure-storage-blob-manager-sample)) with a SharePoint document library downloader.
  2. The SP downloader SharePoinDriveItemDeltaDownloader is requesting a site id and list id.

The logic of the downloader is doing this:

  • It asks the user for the SharePoint List ID (or uses an environment variable) and an optional delta marker for incremental sync.
  • Reads credentials from environment variables: It retrieves the necessary Azure AD and SharePoint credentials.
  • Initializes the Microsoft Graph client: Authenticates and prepares to interact with the SharePoint API.
  • Finds the correct drive and root folder: Looks up the drive and root folder for the specified SharePoint list.
  • Fetches items using the delta API: Retrieves the first page of items (or resumes from a delta marker), then continues paging through results if more are available.
  • Processes each item: For each file or folder, it logs details and (optionally) downloads files that have changed.
  • Tracks and summarizes results: Counts downloaded and skipped files, and prints a summary including the new delta link for future incremental syncs.

Getting a sample for driveitem delta endpoint just like the sample for users would be nice!

Microsoft Security | Microsoft Graph
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.