如何使用Microsoft Graph获取并筛选SharePoint文件夹内的列表项?
Let's tackle your two questions one by one—SharePoint list folders have a bit of a unique relationship with list items in Graph, so I'll break this down clearly.
1. How to get list items inside a SharePoint folder with Microsoft Graph?
First, keep in mind that in SharePoint, a "folder" in a list is actually a list item with the Folder content type. That means we first need to locate the folder itself as a list item, then fetch its child items. Here's the step-by-step:
Step 1: Get your target site
You can identify the site using its ID, or use the domain + site path for easier reference:GET https://graph.microsoft.com/v1.0/sites/{your-domain}:/{site-path}Grab the
idvalue from the response—this is yoursite-id.Step 2: Get your target list
Use the site ID to fetch the list (either by list ID or display name):GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-name-or-id}Save the
idhere as yourlist-id.Step 3: Locate the folder as a list item
Filter the list items to find the folder you want (by title, for example):GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?filter=ContentType/Name eq 'Folder' and Title eq 'Your Target Folder'&select=id,TitleThe
idin the response is the unique ID of the folder as a list item—we'll call thisfolder-item-id.Step 4: Fetch items inside the folder
Now filter the list items to only those contained within this folder using theFolder/Idproperty:GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?filter=Folder/Id eq '{folder-item-id}'&expand=FolderAdding
&expand=Folderwill include details about the parent folder in each item's response, which is helpful for verification.
2. How to filter/get items inside list folders when you can already fetch all list items?
If you're already pulling all items from the list, you just need to add a $filter parameter to narrow down to folder-contained items. Here are two common scenarios:
Get items from a specific folder
Append this filter to your existing request (replace{folder-item-id}with the ID you got from step 3 above):GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?filter=Folder/Id eq '{folder-item-id}'Get all items that are inside any folder (exclude root-level items)
If you want to exclude items that are directly in the list root (not in any folder), use this filter:GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?filter=Folder ne null
Quick Notes:
- Permissions: Make sure your app has the right permissions—
Sites.Read.All(read-only) orSites.ReadWrite.All(if you need to modify items) should work. - Case sensitivity: SharePoint content type names and titles are case-sensitive in Graph filters, so match the exact casing used in your site.
- Pagination: If you have more than 200 items, don't forget to handle pagination with
@odata.nextLinkin the response.
内容的提问来源于stack exchange,提问作者Ehsan Mahpour

