How to filter SharePoint list item by ID using Microsoft Graph Api using C#?

1 Answer 1


If you are trying to fetch the SharePoint list item using item Id, you can use HTTP API like:


Using C#:

// Code snippets are only available for the latest version. Current version is 5.x

// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites["{site-id}"].Lists["{list-id}"].Items["{listItem-id}"].GetAsync((requestConfiguration) =>
    requestConfiguration.QueryParameters.Expand = new string []{ "fields" };

Source Documentation:

MS Graph - Get listItem

  • Thank you much for the reply. Issue using this is, if a {listItem-id} not exists, .Items["{listItem-id}"] throws error.
    – user109360
    Commented Jan 14 at 10:21
  • You're welcome. If you are trying to get the list item by using ID, there should be an item with ID in the list. If you are using a variable for storing item ID and passing it to the API, you can first check if the variable is empty or not and call API conditionally OR if variable is having valid number but the item is not present in the list (maybe item deleted after creation or you are using wrong ID), you should use try-catch and exception handling in such cases. Commented Jan 14 at 16:48
  • Thank you! Can we have a filter query using listItem-id so that an error can be avoided, if item not exists.
    – user109360
    Commented Jan 14 at 17:17
  • Try something like this: https://graph.microsoft.com/v1.0/sites/16f13df6-5f4k-4168-8165-ddc5ca261dd0/lists/5d9b63cd-5630-476d-b5fb-1641f07a630d/items?expand=fields(select=id,Title)&filter=(fields/id eq '2'). Check this and this. Commented Jan 15 at 5:18
  • Thank you! Using id in filter query, its getting an error 'A provided field name is not recognized'.
    – user109360
    Commented Jan 15 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.