【问题标题】:Unable to access the Sharepoint List using Microsoft Graph API--无法使用 Microsoft Graph API 访问 Sharepoint 列表--
【发布时间】:2017-10-09 00:40:30
【问题描述】:

使用 Microsoft graph api,尤其是 sharepoint beta api,我经常遇到问题。我知道它的测试版,但仍然;)

所以问题是当我尝试在图形资源管理器中使用图形 API 访问共享点列表时 网址为:GET https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}

所以 SiteID 我将我的站点租户 GUID 和列表 ID 作为 Sharepoint 列表 GUID 传递 我在响应中不断面临错误

{ “错误”: { “代码”:“无效请求”, "message": "提供的 id 不适合当前主机", “内部错误”:{ “请求 ID”:“61efc5b1-88f8-442c-a41d-7213b587318e”, “日期”:“2017-05-10T07:38:04” } } }

如果有人也遇到过这个问题,请告诉我你已经解决的解决方案

【问题讨论】:

    标签: microsoft-graph-api


    【解决方案1】:

    试试https://graph.microsoft.com/beta/sites/{siteCollectionId},{siteId}/lists

    你可以从https://graph.microsoft.com/beta/site/sites找到这些id

    【讨论】:

      【解决方案2】:

      作为本周 API 更新的一部分,网站 ID 的格式已更改。新的format is documented here,但它包含 SharePoint 主机名、SPSite.ID 和 SPWeb.ID 作为三元组:

      https://graph.microsoft.com/beta/sites/contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8
      

      如果您将主机名添加到您的 ID 中,您的调用应该会再次开始工作。您可以通过向以下地址发出请求来发现主机名:

      https://graph.microsoft.com/beta/sites/root/siteCollection/hostname
      

      您现在还可以使用以下搜索语法搜索网站:

      https://graph.microsoft.com/beta/sites?search={keyword}
      

      【讨论】:

        【解决方案3】:

        @Ryan Gregg 有正确答案

        SiteId 不仅仅是一个 GUID,而是 的组合。

        示例:<contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8>

        上面示例中的整个字符串是您应该在请求中为 {SiteId} 传递的内容

        如果您没有 SPSite.ID 但有站点的 URL,则可以使用站点的相对路径进行 GRAPH API 调用

        https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Documetation
        

        此调用将返回站点的所有属性,您可以从此处获取完整的 SiteId

        {
            "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
            "createdDateTime": "2020-04-23T12:18:48.653Z",
            "description": "Documentation",
            "id": "contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8",
            "lastModifiedDateTime": "2020-12-09T19:17:21Z",
            "name": "Documentation",
            "webUrl": "https://contoso.sharepoint.com/sites/Documentation",
            "displayName": "Documentation",
            "root": {},
            "siteCollection": {
                "hostname": "contoso.sharepoint.com"
            }
        }
        

        【讨论】:

          猜你喜欢
          • 2019-04-01
          • 2020-07-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多