【问题标题】:Get all root sites listed in share point Admin center using graph api beta使用 graph api beta 获取共享点管理中心中列出的所有根站点
【发布时间】:2017-04-26 09:16:09
【问题描述】:

我需要图片中显示的共享点管理中心中列出的所有根站点

为此,我正在使用如下所示的 Graph api,

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://graph.microsoft.com/beta/sharepoint/sites",
  "method": "GET",
  "headers": {
    "authorization": "Bearer token",
    "cache-control": "no-cache",
    "postman-token": "3116b007-e574-5ad4-aedd-3b35fbf76b61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

但它给出的输出如下,

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#sharePoint/sites",
  "value": [
    {
      "createdDateTime": "2017-02-18T13:03:01.263Z",
      "description": "",
      "id": "2422c3a2-3c51-40f1-8483-5454aead43c4,412bb897-c754-460a-962d-db22893a1649",
      "lastModifiedDateTime": "2017-04-24T02:16:43Z",
      "name": "",
      "webUrl": "https://mps330124.sharepoint.com",
      "root": {},
      "siteCollection": {
        "hostname": "mps330124.sharepoint.com"
      },
      "siteCollectionId": "2422c3a2-3c51-40f1-8483-5454aead43c4",
      "siteId": "412bb897-c754-460a-962d-db22893a1649"
    }
  ]
}

我如何使用 graph api beta

来实现它

【问题讨论】:

    标签: sharepoint graph outlook office365 microsoft-graph-api


    【解决方案1】:

    在站点搜索端点上使用星号似乎可以工作

    https://graph.microsoft.com/v1.0/sites?search=*
    

    返回

    {
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
    "value": [
        {
            "createdDateTime": "2017-09-15T01:11:50Z",
            "description": "Let's capture our thoughts in this subsite blog.",
            "id": "xyz.sharepoint.com,5a58bb09-1fba-41c1-8125-69da264370a0,5e9767b8-95bc-4bd1-aeb0-defabcdefabc",
            "lastModifiedDateTime": "0001-01-01T08:00:00Z",
            "name": "internalblogs",
            "webUrl": "https://xyz.sharepoint.com/internalblogs",
            "displayName": "Internal blog"
        },
        {   
            ...
        }]
    }
    

    【讨论】:

    • 重要提示:这仅适用于 v1.0 端点,如果您在 beta 端点上使用它,它将失败。我也不确定这是否意味着此选项将在未来的版本中被弃用
    • 这很好,工作。似乎 Klipfolio 使用了这个。
    • 因为这是使用搜索索引。这不会为您提供网站集的实时视图。在某些情况下,网站集也不会在此处返回。这里有一个用户语音功能请求officespdev.uservoice.com/forums/…
    • 另外不要忘记,这个查询不会返回所有结果。默认只返回 200 个结果。
    【解决方案2】:

    无法通过 Microsoft Graph 检索网站集的完整列表。该功能在 SharePoint API 中为“仅限管理员”,尚未通过 Microsoft Graph 提供。

    我们正在对 Microsoft Graph 的 SharePoint 站点 API 进行一些更改,这些更改将在接下来的几周内推出,以便搜索网站/网站集列表,但我们仍然没有计划提供通过 Microsoft Graph 枚举所有网站/网站集的能力。

    在 Build 2017 会议(5 月 10 日至 12 日)期间观看 Change Log,了解我们的所有详细信息。

    【讨论】:

    • Ryan,您介意分享一下今天可以使用哪种 SharePoint API 功能来检索此信息吗?我们目前使用 CSOM,但我不确定是否有更好的方法允许我们使用纯 OAuth 令牌来检索这些数据。如果 Sites API 包含某种机制来检索它,那就太好了。
    • 关于检索顶级网站集列表的最佳方式是否有任何更新?
    【解决方案3】:

    现在似乎有一种方法可以通过以下请求获取顶级网站集的列表:

    GET https://graph.microsoft.com/beta/sites?select=siteCollection,webUrl&filter=siteCollection/root%20ne%20null
    

    以下页面记录了这一点(9 月 19 日更新):https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/site_list

    我自己的测试虽然没有取得任何成果,因为 API 返回了 Cannot enumerate sites 错误。另一种方法是使用search 查询参数(docs 9 月 20 日更新):

    GET https://graph.microsoft.com/beta/sites?search=contoso&select=siteCollection,WebUrl&filter=siteCollection/root ne null
    

    但这仅为root 提供siteCollection:/ 以及所有sites 及其webUrl 的其他siteCollection's 的列表(就像默认的/sites/teams)但不是它们所属的siteCollection 的实际 url/主机名。虽然这可以从webUrl 路径组件中提取出来。

    【讨论】:

      【解决方案4】:

      你得到的不是错误。

      如果您使用 URL https://graph.microsoft.com/beta/sharepoint/sites/2422c3a2-3c51-40f1-8483-5454aead43c4/sites 跟随 siteCollectionId,您将获得该网站集中的网站列表。

      【讨论】:

      • 您好,抱歉,这不是错误。我打错了。我试过网址graph.microsoft.com/beta/sharepoint/sites/…。它将仅提供请求的“站点集合(2422c3a2-3c51-40f1-8483-5454aead43c4/)”的子站点。但我需要所有根级站点。
      猜你喜欢
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 2021-07-31
      • 2021-10-27
      • 1970-01-01
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多