The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Hi,
What you’re experiencing is consistent with search indexing latency in SharePoint and OneDrive.
According to Microsoft’s documentation, SharePoint content must be crawled and added to the search index before it can appear in search results. Microsoft also acknowledges that missing search results can be related to crawl latency or search configuration.
Since the same query returns the documents a few minutes later, indexing latency is a reasonable explanation for the behavior you’re seeing, although it cannot be confirmed as the sole cause without further investigation.
Unfortunately, there is no documented way to guarantee immediate indexing through the Microsoft Graph Search API.
Depending on how your application handles shared documents, there are a few approaches you can consider:
- If the document ID is already known: Use GET /drives/{drive-id}/items/{item-id} to retrieve the file’s metadata directly, provided the application has the necessary access permissions. This does not depend on Search indexing.
- If a sharing link is available: You can use GET /shares/{shareIdOrEncodedSharingUrl}/driveItem to access the shared item, subject to the required authentication and permissions.
- If your application relies on Search to discover newly shared documents: Implement a retry mechanism with exponential backoff and a reasonable timeout. This can help accommodate indexing delays, but it will not accelerate the indexing process.
One important consideration is that the Search API is not a direct, feature-equivalent replacement for the deprecated /sharedWithMe endpoint. Search returns indexed content matching the query and accessible to the signed-in user, rather than a dedicated collection of all items shared with that user.
Microsoft has documented that /sharedWithMe is deprecated and will stop returning data after November 2026. However, I haven’t found a documented one-to-one replacement that provides the same shared-file discovery functionality.
If documents consistently fail to appear even after allowing time for indexing, it would be worth investigating the site’s search configuration and the affected user’s permissions.
For reference:
- Search results missing in SharePoint Online
- Use the Microsoft Search API to search OneDrive and SharePoint content
- Get driveItem
- drive: sharedWithMe (deprecated)
Could you clarify whether your application needs to automatically discover all newly shared documents without knowing their file IDs or sharing links beforehand, or whether it only needs immediate access to specific documents after they are shared? This would help determine which approach best fits your scenario.