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

问题描述 投票:-1回答:2

我需要从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
    )

没有列出任何活动。我还尝试了Microsoft's API reference docs上显示的/ sites / {site-id} / lists / {list-id} / items。这不显示事件。是否有可能以这种方式提取事件?

sharepoint office365 microsoft-graph
2个回答
0
投票

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

enter image description here

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

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


0
投票

关于

没有列出任何活动。我还尝试了/ sites / {site-id} / lists / {list-id} / items,如Microsoft的API参考文档所示。这不显示事件

最有可能的是,因为每个日历启用了“项目级别”权限。

如何验证

  • 转到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将仅返回当前用户创建的事件


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

1)通过将日历设置为Read all items来禁用每个日历的项级别权限

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

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

enter image description here

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

© www.soinside.com 2019 - 2024. All rights reserved.