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

调用Microsoft Graph /sites?search接口时未返回Root Site Facet

Issue: Root Site Facet Missing from /sites?search Response in Microsoft Graph

我之前碰到过这个问题,刚好可以给你解答:当调用Microsoft Graph的/sites?search搜索站点时,默认返回的响应里确实不会包含Root Site Facet,这是因为该端点的默认字段集合不包含这个facet信息。

你的示例请求

GET https://graph.microsoft.com/v1.0/sites?search=fake Archive

对应的返回结果(无Root Site Facet)

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
  "value": [
    {
      "createdDateTime": "2017-11-04T18:52:44Z",
      "id": "fakeau.sharepoint.com,0f736b6a-d7fa-498d-b13f-72af82d58b49,7c055ac7-0d31-4341-8158-8055950f37c8",
      "lastModifiedDateTime": "2017-11-14T23:21:51Z",
      "name": "fake ..."
    }
  ]
}

解决办法:使用$select显式指定root字段

要获取Root Site Facet,你只需要在请求中添加$select参数,明确列出你需要的字段(包括root)。修改后的请求如下:

GET https://graph.microsoft.com/v1.0/sites?search=fake Archive&$select=id,name,createdDateTime,lastModifiedDateTime,root

这样返回的结果就会包含Root Site Facet的信息,示例响应大概是这样:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites(id,name,createdDateTime,lastModifiedDateTime,root)",
  "value": [
    {
      "createdDateTime": "2017-11-04T18:52:44Z",
      "id": "fakeau.sharepoint.com,0f736b6a-d7fa-498d-b13f-72af82d58b49,7c055ac7-0d31-4341-8158-8055950f37c8",
      "lastModifiedDateTime": "2017-11-14T23:21:51Z",
      "name": "fake ...",
      "root": {
        "siteCollection": {
          "hostname": "fakeau.sharepoint.com",
          "dataLocationCode": "AUS",
          "id": "0f736b6a-d7fa-498d-b13f-72af82d58b49"
        },
        "webUrl": "https://fakeau.sharepoint.com/sites/fakeArchive"
      }
    }
  ]
}

补充说明

Microsoft Graph的搜索类端点默认只会返回最基础的字段集合,目的是减少响应数据体积、提升请求效率。如果需要获取特定的facet或者扩展字段,都需要通过$select参数明确指定需要的字段。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 07:46:03