根据文件,我可以使用以下图形API列出Office 365组:
GET https://graph.microsoft.com/v1.0/groups
我有一个C# Web应用程序,并且有一个由Group DisplayName进行搜索的输入。知道如何基于DisplayName查询组吗?
我尝试了以下网址:https://graph.microsoft.com/v1.0/groups?$search="displayName:Test"在MS图形资源管理器中没有工作。
我得到以下错误。
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "This query is not supported.",
"innerError": {
"request-id": "35d90412-03f3-44e7-a7a4-d33cee155101",
"date": "2018-10-25T05:32:53"
}
}欢迎任何建议。提前谢谢。
发布于 2018-10-25 07:24:28
根据您的描述,我假设您希望使用搜索参数通过DisplayName搜索组。
基于本文件,我们目前只能搜索消息和人员集合。所以我们不能使用搜索参数。
我们可以使用filter查询参数通过DisplayName搜索组。例如,我们可以搜索displayName以'Test‘开头的组,请求url如下所示:
https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'Test')
发布于 2019-06-24 17:39:39
下面是我编写的C#代码,用于使用DisplayName获取一个组。此代码需要对OfficeDevPnP.Core的引用。
private static async Task<Group> GetGroupByName(string accessToken, string groupName)
{
var graphClient = GraphUtility.CreateGraphClient(accessToken);
var targetGroupCollection = await graphClient.Groups.Request()
.Filter($"startsWith(displayName,'{groupName}')")
.GetAsync();
var targetGroup = targetGroupCollection.ToList().Where(g => g.DisplayName == groupName).FirstOrDefault();
if (targetGroup != null)
return targetGroup;
return null;
}发布于 2021-04-13 15:39:06
更新
我看到这个答案已经被接受了,但我遇到了同样的问题,发现这个答案已经过时了。对于下一个用户,这是更新
“搜索”功能确实有效。我不确定它是一路走来的,还是一直固定着的。
第四点是绊倒我的原因!
您的请求如下所示:
https://graph.microsoft.com/v1.0/groups?$search="displayName:Test"
使用请求头: ConsistencyLevel:最终
https://stackoverflow.com/questions/52982512
复制相似问题