Microsoft Graph Client SDK -filter groups by name
一个相当简单的问题,但我无法将查询 Graph 的基本
1 2 | var filter ="IT"; var response = await httpClient.GetAsync($"{webOptions.GraphApiUrl}/beta/groups?$filter=startswith(displayName, '{filter}')&$select=id,displayName"); |
...现在我正在尝试使用 SDK 进行过滤,如下所示:
1 2 3 4 5 | var groups = await graphServiceClient.Groups .Request() .Filter($"displayName startswith {filter}") .Select("id, displayName") .GetAsync(); |
我也尝试过
我收到一个
显然这是因为为
1 2 3 4 | var message = graphServiceClient.Groups .Request() .Filter($"displayName startswith '{filter}'") .Select("id, displayName").GetHttpRequestMessage(); |
生成的
1 | https://graph.microsoft.com/v1.0/groups?$filter=displayName startswith '{filter}'&$select=id, displayName} |
需要像这样指定一个有效的过滤器表达式:
1 | .Filter($"startswith(displayName, '{filter}')") |
如果您想为
1 | graphServiceClient.BaseUrl ="https://graph.microsoft.com/beta"; |