Not able to call SharePoint Document Library driveitems using MS Graph API with filter functions 'contains' and 'endswith'.

Gautam, Priyamvada 0 Reputation points
2025-01-06T14:54:27.92+00:00

We need to get files from the SharePoint Document Library with a filter that uses 'contains' and 'endswith'.

The query goes as below:

https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/items?$filter=contains(Name,'100001') and endswith(parentReference/path,'EXPIRED')

This query worked initially but stopped working after 15th December. It returns all the items in the library and the filter doesn't work.

Can you please help and suggest?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,717 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,171 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Akhil Nasalwai - MSFT 85 Reputation points Microsoft Vendor
    2025-01-06T16:57:30.94+00:00

    Hello Gautam, Priyamvada,

    Thank you for contacting Microsoft!

    Regarding the query unable to call SharePoint Document Library drive items using MS Graph API with filter functions 'contains' and 'endswith', I have tried replicating the issue and seems to be working fine as attached in the screenshot below.

    endswith filter in sharepoint

    Here are few work arounds that might help you:

    Hope this helps.

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

    0 comments No comments

  2. Ling Zhou_MSFT 20,090 Reputation points Microsoft Vendor
    2025-01-07T06:11:42.1933333+00:00

    Hi @Gautam, Priyamvada,

    Thanks for your detailed explanation, I am more than willing to help you out.

    Based on the information you provided, I tested the same request and found that I encountered the same situation as you did: the filter failed and it didn't filter any content.

    To confirm if this is a common problem, I asked my other colleagues to run the same test but again the filter did not work.

    We suspect that the filter has likely recently undergone an internal update that caused it to fail. Since our team in charge of the forums does not have sufficient access to update logs regarding the internals of the MS Graph product, it would be advisable to open a ticket to inquire about this.

    We are sorry to hear that the filters in this Graph API don't work anymore, we apologize for any inconvenience this may cause.

    Certainly, if you have any other concerns, I will be always readily to support you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. It will be beneficial to more community members reading here.

    0 comments No comments

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.