简体   繁体   English

Microsoft Graph API - 如何按网站类型过滤 SharePoint 网站?

[英]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.

相关问题 如何在 Microsoft Graph API 中过滤 Sharepoint 术语? - How to filter Sharepoint Terms in Microsoft Graph API? SharePoint 站点搜索使用 Microsoft Graph api 返回已删除的站点 - SharePoint sites search using Microsoft Graph api returns deleted sites Microsoft Graph API - 仅共享 Sharepoint 站点 - Microsoft Graph API - Share Sharepoint site only 如何在 Microsoft Graph API 中使用过滤器来获取 SharePoint 项目? - How to use filter in Microsoft Graph API to get SharePoint items? 通过 Microsoft Graph API 从 SharePoint 获取所有网站 - Fetch all sites from SharePoint by Microsoft Graph API 如何使用 Microsoft Graph API 查找所有站点 - How to lookup all sites with the Microsoft Graph API 如何通过图形 API 检索 SharePoint 现代站点的(团队站点和通信站点)分类属性? - How do I retrieve the SharePoint Modern site's (Team sites and Communication sites) classification property via Graph API? 如何使用 Microsoft Graph 或 SharePoint API 获取每个 SharePoint 站点的大小? - How to get the size of each SharePoint site using Microsoft Graph or SharePoint API? 如何使用 sharepoint API 或 Microsoft Graph 从 sharepoint 站点上的文件夹请求文件内容? - How to request file content from a folder on a sharepoint site using sharepoint API or Microsoft Graph? 使用Microsoft Graph列出Microsoft Sharepoint站点 - List Microsoft Sharepoint Sites with Microsoft Graph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM