我可以使用Microsoft Graph访问Sharepoint日历吗?

时间:2018-09-05 22:44:54

标签: sharepoint office365 microsoft-graph

我需要从SharePoint上的共享日历中提取事件。

使用Microsoft Graph我已经找到了日历:

https://graph.microsoft.com/v1.0/sites/company.sharepoint.com/lists/CALENDAR_ID

其中包括一个列表数组。然后,我尝试了:

https://graph.microsoft.com/v1.0/sites/company.sharepoint.com/lists/CALENDAR_ID/list

哪个返回:

 [_decodedBody:Microsoft\Graph\Http\GraphResponse:private] => Array
    (
        [@odata.context] => https://graph.microsoft.com/v1.0/$metadata#sites('company.sharepoint.com')/lists('CALENDAR_ID')/list
        [contentTypesEnabled] => 1
        [hidden] => 
        [template] => events
    )

没有列出事件。我也尝试过 / sites / {site-id} / lists / {list-id} / items ,如Microsoft's API reference docs所示。这不显示事件。这样可以提取事件吗?

2 个答案:

答案 0 :(得分:0)

首先,对于问题,您提到了“ / sites / {site-id} / lists / {list-id} / items ” 仅在graph api beta版本中可用,是的,请勿在产品的生产版本中使用它。

enter image description here

https://.sharepoint.com/site//_api/web/lists/getbytitle('Calendar')/items

请尝试使用上面的代码来检索您的日历项目。

答案 1 :(得分:0)

关于

  

没有列出事件。我也尝试过   / sites / {site-id} / lists / {list-id} / item,如Microsoft API所示   参考文档。这不显示事件

最有可能发生这种情况,因为每个日历都启用了 Item Level权限

如何验证

  • 在SharePoint UI中转到“日历”设置: /_layouts/15/listedit.aspx?List={list-id}
  • Advanced Settings下验证是否选择了Read items that were created by the user

enter image description here

如果选择了Read items that were created by the user选项,则端点https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items将仅返回由当前用户

创建的事件

为了返回 all 事件,可以考虑以下选项:

1)通过将其设置为Read all items

来禁用每个日历的项目级别权限。

2)或利用SharePoint API终结点检索所有事件:https://server/_api/web/lists/getbyid('<list-id>')/items

根据用户权限,您可能需要启用Override List Behaviors权限级别

enter image description here

否则,权限受限的用户将无法检索所有事件

相关问题