I use this documentation - https://docs.microsoft.com/ru-ru/graph/api/channel-post-members?view=graph-rest-1.0&tabs=csharp,http.
I get this message, when I want to add member in channel enter image here
var conversationMember = new AadUserConversationMember
{
Roles = new List<String>()
{
},
AdditionalData = new Dictionary<string, object>()
{
{userBind, $"https://graph.microsoft.com/v1.0/users('{userId}')"}
}
};
await graphClient.Teams[$"{teamId}"].Channels[$"{channelId}"].Members
.Request()
.AddAsync(conversationMember);// Here I get error
I created channel here
var team = new Team
{
DisplayName = department.Name,
Channels = new TeamChannelsCollectionPage()
{
},
Members = new TeamMembersCollectionPage()
{
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{ userBind, $"https://graph.microsoft.com/v1.0/users('{ownerId}')" }
},
}
},
AdditionalData = new Dictionary<string, object>()
{
{ templateBind, urlTeamsApiStandard },
}
};
foreach (var bitrixChannel in department.Channels)
{
var channel = new Channel
{
DisplayName = bitrixChannel.Name,
MembershipType = ChannelMemberShipType.Private // Here I choose private, which doesnt work
};
team.Channels.Add(channel);
}
await graphClient.Teams
.Request()
.AddAsync(team);
What is wrong?
UPD: I found that my channels in ms teams creates in not private mode, even if I choosed private. But I don't understand why
CodePudding user response:
Adding conversationMember to the channel, this operation is only allowed for channels with a membershipType value private which explains the error.
If this is useful, consider upvoting.
Thanks.
CodePudding user response:
I found that I have to use
await graphClient.Teams[teamId].Channels
.Request()
.AddAsync(channel);