[英]Microsoft Graph API - How to Filter SharePoint sites by Site Type?
SharePoint Admins in Microsoft 365 can create Team Sites and Communication Sites using the admin center. Microsoft 365 中的 SharePoint 管理员可以使用管理中心创建团队网站和通信网站。
In addition, individual users can have Personal Sites (Otherwise known as My Sites )此外,个人用户可以拥有个人站点(也称为我的站点)
Using the Microsoft Graph .NET SDK I can retrieve all sites like this:-使用 Microsoft Graph .NET SDK,我可以像这样检索所有站点:-
await client.Sites.Request().GetAsync();
However this appears to include all Team, Personal and Communication Sites.但是,这似乎包括所有团队、个人和通信站点。 Is there a way to limit the request to only one type of site, or detect the type of each site returned from the query?
有没有办法将请求限制为仅一种类型的站点,或者检测从查询返回的每个站点的类型? I could not find anything in the documentation about this.
我在文档中找不到任何关于此的内容。
Edit: If there's a way to get this information via SharePoint CSOM, I would be interested in that too编辑:如果有办法通过 SharePoint CSOM 获取此信息,我也会对此感兴趣
Unfortunately this is not available as of now but there is a uservoice already raised.不幸的是,这是不作为的,但现在有一个UserVoice的已经提高。 Please upvote it so that this feature may be implemented in the future.
请为它点赞,以便将来可以实现此功能。
I don't know if it can help you but I found a workaround how to differentiate between a team/communication site and a personal site.我不知道它是否可以帮助您,但我找到了如何区分团队/通信站点和个人站点的解决方法。
A personal site contains in the WebUrl field the string "my.sharepoint.com/personal/"
, then after you make the call:个人站点在WebUrl字段中包含字符串
"my.sharepoint.com/personal/"
,然后在您拨打电话后:
var sites = await client.Sites.Request().GetAsync();
you can use this filter to retrieve only personal site:您可以使用此过滤器仅检索个人站点:
var personalSites = sites.Where(s => s.WebUrl.Contains("my.sharepoint.com/personal/"))
; var personalSites = sites.Where(s => s.WebUrl.Contains("my.sharepoint.com/personal/"))
;
(Microsoft does not allow to use a filter on this request directly, so this is the reason why I used the filter after fetching all sites.) (微软不允许直接在这个请求上使用过滤器,所以这就是我在获取所有站点后使用过滤器的原因。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.