Graph API SharePoint List Search (Contains & StartsWith) Not Working

L.K.Prabu 26 Reputation points
2022-09-21T06:21:39.557+00:00

Hi,

I am trying to search the SharePoint List items through Graph API using the keyword filter=contains({fieldname}, '{fieldvalue}') also tried with filter=startswith({fieldname}, '{fieldvalue}'). In the fieldvalue I have given some string values, but it seems both the conditions is not working.

Just want to confirm if Graph API supports contains & startswith keywords?

Thanks in Advance.

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-09-21T15:57:57.917+00:00

    Hi @L.K.Prabu ,

    Microsoft Graph for listitem-list, $filter supports startsWith on text fields only, currently there is no support for contains function.

    GET /sites/{siteId}/lists/{listId or Title}/items?$expand=fields&$filter=startsWith(fields/{fieldName},'{stringValue}')  
    Prefer: HonorNonIndexedQueriesWarningMayFailRandomly  
    

    My test result with startsWith
    243532-image.png
    From your test try changing ?expand=fields&filter=contains(fields/AccountNumber, '1102') to ?$expand=fields&$filter=startsWith(fields/AccountNumber, '1102'), and it would work only if AccountNumber is a text filed type.

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

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.