[英]Getting a specified user from Graph API
I'm stuck trying to figure out how to return a single specified user via Graph API.我一直在试图弄清楚如何通过 Graph API 返回单个指定的用户。 I'm able to return all users, but unfortunately their documentation doesn't state exactly how to return one user.我能够返回所有用户,但不幸的是,他们的文档并没有确切说明如何返回一个用户。 I would like to get a single user via CLI arguments, but I do not see how to do that.我想通过 CLI 参数获得单个用户,但我不知道如何做到这一点。 FWIW, here's the documentation https://docs.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http It specifies to use await graphClient.Me.Request().GetAsync();
FWIW,这里是文档https://docs.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http它指定使用await graphClient.Me.Request().GetAsync();
but that only returns the current logged in user's details.但这仅返回当前登录用户的详细信息。 The only other option I see is to get all users via await graphClient.Users.Request().GetAsync();
我看到的唯一其他选择是通过await graphClient.Users.Request().GetAsync();
获取所有用户await graphClient.Users.Request().GetAsync();
and parse out the data from that some how.并从中解析数据。
I know the following code doesn't work, but this is my logic of what I'd like to do ( name
is a CLI argument)我知道以下代码不起作用,但这是我想要做的事情的逻辑( name
是 CLI 参数)
static async Task GetUser(GraphServiceClient graphClient, string name)
{
var users = await graphClient.Users.Request().GetAsync();
var user = await graphClient.Users[users.name].Request().GetAsync();
想通了,不幸的是它没有记录在任何地方,但它确实允许过滤。
var users = await graphClient.Users.Request().Filter($"DisplayName eq '{name}'").GetAsync();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.