简体   繁体   English

从 Graph API 获取指定用户

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

相关问题 Microsoft Graph API。获取用户活动 - Microsoft Graph API. Getting user activity 使用AcquireTokenByUsernamePassword方法为联盟用户获取图形API令牌 - Getting graph api token using AcquireTokenByUsernamePassword method for a Federated user Facebook Graph API在用户未登录时获取数据 - Facebook Graph API getting data when user not logged in 通过 AppID+Appsecret 从图 API 获取 FB accesstoken - Getting FB accesstoken from graph API by AppID+Appsecret C# - Microsoft Graph API - 从自定义列表中获取图片 - C# - Microsoft Graph API - Getting Pictures from Customlist 如何从Facebook Graph Api获取用户电子邮件? - How to get a user email from Facebook Graph Api? 从 Graph Api 中获取特定用户的托管设备? - Get managed devices from specific user in Graph Api? 使用UWP中的microsoft Graph API为登录用户获取特定日期的会议邀请和事件 - Getting meeting invites & events for the specific day for the logged in user using microsoft Graph API in UWP 根据当前用户登录到全名从 SQL 表中获取指定值 - getting specified value from SQL table based on current user login to Full name 使用图API通过用户ID从Facebook获取用户的创建事件 - get user's create events from facebook by user id using graph api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM