简体   繁体   English

图 api 获取频道成员无法获取 userId

[英]Graph api get members of channel not able get the userId

the response of the get members of the channels has userid, when we debugg it we can find it in the response通道get成员的response是有userid的,调试的时候可以在response中找到

but when we try to但是当我们尝试

 var response = await graphClient.Teams[teamid].Channels[channeId].Members
                        .Request()
                        .GetAsync();
        foreach (var res in response)
        {
            var member = new Members();
            member.UserId = res.Id;      //this id is not user id 
            member.FullName = res.DisplayName;
            members.Add(member);
        }

The response has userId, not able to get the userID, how do we retrive userId响应有userId,获取不到userID,如何取回userId

I assume your debug code is accessing the beta api, while the your code snippet is using the v1.0 api.我假设您的调试代码正在访问测试版 api,而您的代码片段正在使用 v1.0 api。

GET https://graph.microsoft.com/beta/Teams/02bd9fd6-8f93-4758-83-1fb73740a315/channels/19:09fc54a3141a45d0bc769cf506d279@thread.skype/members

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#teams('09fd6-8f93-4758-87c3-1fb73740a315')/channels('19%3A09fc54a3141a45d0b69cf506d2e079%40thread.skype')/members",
    "@odata.count": 19,
    "value": [
        {
            "@odata.type": "#microsoft.graph.aadUserConversationMember",
            "id": "MCMjMiMjZGNkMjE5ZGQtYmM2OC00YjliLWJmMGItNGEzM2E3OTZiZTM1IyMxOTowOWZjNTRhMzE0MWE0NWQwYmM3NjljZjUwNmQyZTA3OUB0aHJlYWQuc2t5cGUjIzA3NGU1NmVhLTBiNTAtNDQ2MS04OWU1LWM2N2FlMTRhMmMwYg==",
            "roles": [],
            "displayName": "Lee Gu",
            "visibleHistoryStartDateTime": "0001-01-01T00:00:00Z",
            "userId": "074e56ea-0b50-4461-89e5-ae14a2c0b",
            "email": "LeeG@M365x2143.onmicrosoft.com",
            "te
...

versus the 1.0 api:与 1.0 api 相比:

GET https://graph.microsoft.com/v1.0/Teams/02bd9fd6-8f93-4758-87c3-1fb73740a315/channels/19:09fc54a3141a45d0bc769cf506d2e079@thread.skype/members

{
    "error": {
        "code": "Forbidden",
        "message": "Caller does not have the required permissions for accessing this API. AllowedPermissions:'ChannelMember.Read.All,ChannelMember.ReadWrite.All'",
        "innerError": {
            "date": "2022-02-07T23:54:32",
            "request-id": "d82250a3-9637-4626-8afd-499ea3fd519e",
            "client-request-id": "d82250a3-9637-4626-8afd-499ea3fd519e"
        }
    }
}

the v1.0 api appears to have more stringent permission requirements. v1.0 api 似乎有更严格的权限要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM