SharePoint 网站和图表 API(测试版)- 在网站下找不到任何页面,也无法创建页面(访问被拒绝)

SharePoint Site and Graph API (Beta) - can't find any pages under site and can't create page (access denied)

我目前正在通过 Postman 使用 SharePoint Graph API(测试版)。 我的一切正常,我的 Azure Active Directory 应用程序具有正确的 SharePoint 范围。

我想知道的是:

我有这个网站(子网站,抱歉我的 SharePoint 术语可能不是最好的):

https://graph.microsoft.com/{{api-version}}/sites/COMPANY_NAME.sharepoint.com,070d3261-xxxx-4c69-b186-a83e7ee0b6bb,09bc2cd0-aada-45fb-xxxx-bcdce9d5711e:/kb:/

哪个returns我要找的网站(注意:我截断了json):

{
   "@odata.context": "https://graph.microsoft.com/beta/$metadata#sites/$entity",
   "createdDateTime": "2020-05-18T06:02:28Z",
   "description": "",
   "id": "COMPANY_NAME.sharepoint.com,070d3261-xxxx-4c69-b186-a83e7ee0b6bb,e7808145-aab1-xxxx-bccc-df798f6a36eb",
   "lastModifiedDateTime": "2020-09-23T21:37:37Z",
   "name": "kb",
   "displayName": "Knowledge Base - I removed the rest of the json"
}

但是当我在末尾添加 /pages 时:

https://graph.microsoft.com/{{api-version}}/sites/COMPANY_NAME.sharepoint.com,070d3261-xxxx-4c69-b186-a83e7ee0b6bb,09bc2cd0-aada-45fb-xxxx-bcdce9d5711e:/kb:/pages/

我明白了:

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.sitePage)",
    "value": []
}

现在,我只是去那个网站创建了一个新页面,即使那里已经有页面,所以我知道它们存在。

另一件需要注意的事情是,当我尝试通过 API:

创建新页面时
POST https://graph.microsoft.com/{{api-version}}/sites/{{site-id}}/pages

我明白了:

{
    "error": {
        "code": "accessDenied",
        "message": "Access denied",
        "innerError": {
            "date": "2020-09-27T22:56:06",
            "request-id": "1306506d-caea-4748-99a9-7eee20bb6404",
            "client-request-id": "1306506d-caea-4748-99a9-7eee20bb6404"
        }
    }
}

任何人都可以帮助我理解为什么我的响应中的集合/数组不包含任何页面,以及为什么当我的 AAD 应用程序具有所需的范围并且这些范围得到我的管理员同意时我无法创建新页面

干杯

更新。添加一些屏幕截图:

正如您所说,您正在使用守护程序应用程序,您需要在此处指定正确的权限。 屏幕截图显示您实际上是为 Sharepoint App 权限添加它,请为 Microsoft Graph 权限添加 Sites.ReadWrite.All。正如您在绿色指针上方看到的那样,有 3 个权限(Directory.Read.All、User.Read.All 和 User.Read),在此处添加“Sites.ReadWrite.All”以获取网站页面,这也有帮助您正在创建页面。