Call driveitem by SharePoint graph

Huff Jennifer 20 Reputation points
2025-07-03T01:52:30.8433333+00:00

I wonder how to call the driveitem list in SPO by using Ms Graph, I've tried:

GET https://graph.microsoft.com/v1.0/sites/{SiteId}/drive/root:/children?$filter=createdDateTime 2025-09-09T07:00:00

But got Bad Request 400ms

Is filtering by createdDateTime supported for drive items at all?

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Nghia-P 1,700 Reputation points Microsoft External Staff Moderator
    2025-07-03T09:59:42.73+00:00

    Dear Huff Jennifer

    Welcome to Microsoft Q&A Forum!

    Thank you for reaching out and for bringing this to our attention. 

    We completely understand your need to filter Drive items in SharePoint or OneDrive by their createdDateTime using Microsoft Graph API. This is a very common and reasonable use case, especially when managing or auditing files based on creation dates. 

    Unfortunately, at this time, the Microsoft Graph API does not support the use of the $filter query parameter with the createdDateTime field for Drive items. This limitation is confirmed in Microsoft’s official documentation as well as the broader developer community. 

    While direct server-side filtering isn't supported, you can still achieve your goal using a client-side approach: 

    Retrieve the siteId of your SharePoint site. For example, using:  GET /sites/{hostname}:/sites/{site-name} 

    Use the siteId in your application code (such as in a C# implementation) to access the list of Drive items in the site's document library:  GET /sites/{siteId}/drive/root/children 

    Filter the results locally within your code based on the createdDateTime property. 

    We understand this may not be the most intuitive solution especially given the expectation that such filtering could be done directly via API but using the siteId in your application remains the most reliable approach available at this time. 

    Please also note that results may vary depending on the size of your document library or your testing environment, so we recommend validating the outcome accordingly. 

      This scenario has been discussed frequently in the developer community. You might find the following Microsoft Q&A thread helpful, as it highlights the same limitation and offers additional insights and workarounds that others have shared: Microsoft Graph: how to filter drive items by createdDateTime? – Microsoft Q&A 

    We sincerely apologize once again for the inconvenience caused by this limitation, which we understand may be frustrating especially in scenarios where filtering by creation date is essential. This current behavior is due to technical constraints within the platform, particularly within testing environments.

    Please rest assured that your feedback is valued and will be taken into account as we continue to improve our services to better meet customer needs.

    If you have any further questions or would like to explore different implementation approaches, please don't hesitate to reach out. We're here to support you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".          

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.   


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.