我需要从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//lists//items ,如Microsoft's API reference docs所示 . 这不显示事件 . 是否有可能以这种方式提取事件?
2 回答
首先,对于您提到的问题“ /sites//lists//items ”这仅适用于图形api beta版本,是的,请勿在产品的 生产环境 版本中使用它 .
请尝试以上代码来检索您的日历项目 .
关于
最有可能的是,因为每个日历启用了“项目级别”权限 .
How to verify
转到SharePoint UI中的日历设置:
/_layouts/15/listedit.aspx?List={list-id}
在
Advanced Settings
下验证Read items that were created by the user
是否被选中如果选择
Read items that were created by the user
选项,则 endpointshttps://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items
将仅返回当前用户创建的事件为了返回所有事件,可以考虑以下选项:
1)通过将日历设置为
Read all items
来禁用每个日历的项级别权限2)或利用SharePoint API endpoints 检索所有事件:
https://server/_api/web/lists/getbyid('<list-id>')/items
根据用户权限,您可能需要启用
Override List Behaviors
权限级别否则具有受限权限的用户将无法检索所有事件