You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Microsoft Graph获取并筛选SharePoint文件夹内的列表项?

Using Microsoft Graph to Retrieve SharePoint List Items in Folders

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 id value from the response—this is your site-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 id here as your list-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,Title
    

    The id in the response is the unique ID of the folder as a list item—we'll call this folder-item-id.

  • Step 4: Fetch items inside the folder
    Now filter the list items to only those contained within this folder using the Folder/Id property:

    GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?filter=Folder/Id eq '{folder-item-id}'&expand=Folder
    

    Adding &expand=Folder will 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) or Sites.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.nextLink in the response.

内容的提问来源于stack exchange,提问作者Ehsan Mahpour

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:13:38