Criar canal
Artigo
07/18/2022
11 minutos para o fim da leitura
3 colaboradores
Neste artigo
Namespace: microsoft.graph
Crie um novo canal em uma equipe, conforme especificado no corpo da solicitação.
Nota: Você pode adicionar no máximo 200 membros ao criar um canal privado.
Permissões
Uma das seguintes permissões é obrigatória para chamar esta API. Para saber mais, incluindo como escolher permissões, confira Permissões .
Tipo de permissão
Permissões (da com menos para a com mais privilégios)
Delegada (conta corporativa ou de estudante)
Channel.Create, Group.ReadWrite.All , Directory.ReadWrite.All
Delegada (conta pessoal da Microsoft)
Sem suporte.
Aplicativo
Channel.Create.Group , Channel.Create, Teamwork.Migrate.All, Group.ReadWrite.All *, Directory.ReadWrite.All**
Observações : as permissões marcadas com ** têm suporte apenas para compatibilidade com versões anteriores. Recomendamos que você atualize suas soluções para usar uma permissão alternativa listada na tabela anterior e evite usar essas permissões daqui para frente. Permissões marcadas com * usem consentimento específico do recurso .
Essa API dá suporte a permissões de administrador. Os administradores globais e os administradores do serviço do Microsoft Teams podem acessar equipes das quais eles não são membros.
No futuro, a Microsoft pode exigir que você ou seus clientes paguem taxas adicionais com base na quantidade de dados importados usando o Teamwork.Migrate.All e/ou APIs de migração .
Solicitação HTTP
POST /teams/{team-id}/channels
Cabeçalho
Valor
Autorização
{token} de portador. Obrigatório.
Content-Type
application/json. Obrigatório.
Corpo da solicitação
No corpo da solicitação, fornça uma representação JSON do objeto canal .
Resposta
Se tiver êxito, este método retornará um código de resposta 201 Created e um objeto canal no corpo da resposta.
Exemplos
Exemplo 1: Criar um canal padrão
Solicitação
O exemplo a seguir mostra uma solicitação para criar um canal padrão.
POST https://graph.microsoft.com/v1.0/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels
Content-type: application/json
{
"displayName": "Architecture Discussion",
"description": "This channel is where we debate all future architecture plans",
"membershipType": "standard"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var channel = new Channel
{
DisplayName = "Architecture Discussion",
Description = "This channel is where we debate all future architecture plans",
MembershipType = ChannelMembershipType.Standard
};
await graphClient.Teams["{team-id}"].Channels
.Request()
.AddAsync(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
const channel = {
displayName: 'Architecture Discussion',
description: 'This channel is where we debate all future architecture plans',
membershipType: 'standard'
};
await client.api('/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels')
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphChannel *channel = [[MSGraphChannel alloc] init];
[channel setDisplayName:@"Architecture Discussion"];
[channel setDescription:@"This channel is where we debate all future architecture plans"];
[channel setMembershipType: [MSGraphChannelMembershipType standard]];
NSError *error;
NSData *channelData = [channel getSerializedDataWithError:&error];
[urlRequest setHTTPBody:channelData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Channel channel = new Channel();
channel.displayName = "Architecture Discussion";
channel.description = "This channel is where we debate all future architecture plans";
channel.membershipType = ChannelMembershipType.STANDARD;
graphClient.teams("57fb72d0-d811-46f4-8947-305e6072eaa5").channels()
.buildRequest()
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewChannel()
displayName := "Architecture Discussion"
requestBody.SetDisplayName(&displayName)
description := "This channel is where we debate all future architecture plans"
requestBody.SetDescription(&description)
membershipType := "standard"
requestBody.SetMembershipType(&membershipType)
teamId := "team-id"
result, err := graphClient.TeamsById(&teamId).Channels().Post(requestBody)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Import-Module Microsoft.Graph.Teams
$params = @{
DisplayName = "Architecture Discussion"
Description = "This channel is where we debate all future architecture plans"
MembershipType = "standard"
}
New-MgTeamChannel -TeamId $teamId -BodyParameter $params
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
O exemplo a seguir mostra a resposta.
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade.
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "19:4b6bed8d24574f6a9e436813cb2617d8@thread.tacv2",
"displayName": "Architecture Discussion",
"description": "This channel is where we debate all future architecture plans"
}
Exemplo 2: Criar um canal privado em nome do usuário
Solicitação
O exemplo a seguir mostra uma solicitação para criar um canal privado e adicionar um usuário como proprietário da equipe.
POST https://graph.microsoft.com/v1.0/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels
Content-type: application/json
{
"@odata.type": "#Microsoft.Graph.channel",
"membershipType": "private",
"displayName": "My First Private Channel",
"description": "This is my first private channels",
"members":
[
{
"@odata.type":"#microsoft.graph.aadUserConversationMember",
"user@odata.bind":"https://graph.microsoft.com/v1.0/users('62855810-484b-4823-9e01-60667f8b12ae')",
"roles":["owner"]
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var channel = new Channel
{
MembershipType = ChannelMembershipType.Private,
DisplayName = "My First Private Channel",
Description = "This is my first private channels",
Members = new ChannelMembersCollectionPage()
{
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{"user@odata.bind", "https://graph.microsoft.com/v1.0/users('62855810-484b-4823-9e01-60667f8b12ae')"}
}
}
}
};
await graphClient.Teams["{team-id}"].Channels
.Request()
.AddAsync(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
const channel = {
'@odata.type': '#Microsoft.Graph.channel',
membershipType: 'private',
displayName: 'My First Private Channel',
description: 'This is my first private channels',
members:
[
{
'@odata.type':'#microsoft.graph.aadUserConversationMember',
'user@odata.bind':'https://graph.microsoft.com/v1.0/users(\'62855810-484b-4823-9e01-60667f8b12ae\')',
roles: ['owner']
}
]
};
await client.api('/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels')
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphChannel *channel = [[MSGraphChannel alloc] init];
[channel setMembershipType: [MSGraphChannelMembershipType private]];
[channel setDisplayName:@"My First Private Channel"];
[channel setDescription:@"This is my first private channels"];
NSMutableArray *membersList = [[NSMutableArray alloc] init];
MSGraphConversationMember *members = [[MSGraphConversationMember alloc] init];
NSMutableArray *rolesList = [[NSMutableArray alloc] init];
[rolesList addObject: @"owner"];
[members setRoles:rolesList];
[membersList addObject: members];
[channel setMembers:membersList];
NSError *error;
NSData *channelData = [channel getSerializedDataWithError:&error];
[urlRequest setHTTPBody:channelData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Channel channel = new Channel();
channel.membershipType = ChannelMembershipType.PRIVATE;
channel.displayName = "My First Private Channel";
channel.description = "This is my first private channels";
LinkedList<ConversationMember> membersList = new LinkedList<ConversationMember>();
AadUserConversationMember members = new AadUserConversationMember();
members.additionalDataManager().put("user@odata.bind", new JsonPrimitive("https://graph.microsoft.com/v1.0/users('62855810-484b-4823-9e01-60667f8b12ae')"));
LinkedList<String> rolesList = new LinkedList<String>();
rolesList.add("owner");
members.roles = rolesList;
membersList.add(members);
ConversationMemberCollectionResponse conversationMemberCollectionResponse = new ConversationMemberCollectionResponse();
conversationMemberCollectionResponse.value = membersList;
ConversationMemberCollectionPage conversationMemberCollectionPage = new ConversationMemberCollectionPage(conversationMemberCollectionResponse, null);
channel.members = conversationMemberCollectionPage;
graphClient.teams("57fb72d0-d811-46f4-8947-305e6072eaa5").channels()
.buildRequest()
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewChannel()
membershipType := "private"
requestBody.SetMembershipType(&membershipType)
displayName := "My First Private Channel"
requestBody.SetDisplayName(&displayName)
description := "This is my first private channels"
requestBody.SetDescription(&description)
requestBody.SetMembers( []ConversationMember {
msgraphsdk.NewConversationMember(),
SetRoles( []String {
"owner",
}
SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"user@odata.bind": "https://graph.microsoft.com/v1.0/users('62855810-484b-4823-9e01-60667f8b12ae')",
}
}
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#Microsoft.Graph.channel",
}
teamId := "team-id"
result, err := graphClient.TeamsById(&teamId).Channels().Post(requestBody)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Import-Module Microsoft.Graph.Teams
$params = @{
"@odata.type" = "#Microsoft.Graph.channel"
MembershipType = "private"
DisplayName = "My First Private Channel"
Description = "This is my first private channels"
Members = @(
@{
"@odata.type" = "#microsoft.graph.aadUserConversationMember"
"User@odata.bind" = "https://graph.microsoft.com/v1.0/users('62855810-484b-4823-9e01-60667f8b12ae')"
Roles = @(
"owner"
)
}
)
}
New-MgTeamChannel -TeamId $teamId -BodyParameter $params
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('57fb72d0-d811-46f4-8947-305e6072eaa5')/channels/$entity",
"id": "19:33b76eea88574bd1969dca37e2b7a819@thread.skype",
"displayName": "My First Private Channel",
"description": "This is my first private channels",
"isFavoriteByDefault": null,
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19:33b76eea88574bd1969dca37e2b7a819@thread.skype/My%20First%20Private%20Channel?groupId=57fb72d0-d811-46f4-8947-305e6072eaa5&tenantId=0fddfdc5-f319-491f-a514-be1bc1bf9ddc",
"membershipType": "private"
}
Exemplo 3: Criar um canal no modo de migração
Solicitação
O exemplo a seguir mostra como criar um canal que será usado para importar mensagens.
POST https://graph.microsoft.com/v1.0/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels
Content-Type: application/json
{
"@microsoft.graph.channelCreationMode": "migration",
"displayName": "Import_150958_99z",
"description": "Import_150958_99z",
"createdDateTime": "2020-03-14T11:22:17.067Z"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var channel = new Channel
{
DisplayName = "Import_150958_99z",
Description = "Import_150958_99z",
CreatedDateTime = DateTimeOffset.Parse("2020-03-14T11:22:17.067Z"),
AdditionalData = new Dictionary<string, object>()
{
{"@microsoft.graph.channelCreationMode", "migration"}
}
};
await graphClient.Teams["{team-id}"].Channels
.Request()
.AddAsync(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
const channel = {
'@microsoft.graph.channelCreationMode': 'migration',
displayName: 'Import_150958_99z',
description: 'Import_150958_99z',
createdDateTime: '2020-03-14T11:22:17.067Z'
};
await client.api('/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels')
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphChannel *channel = [[MSGraphChannel alloc] init];
[channel set@microsoft.graph.channelCreationMode:@"migration"];
[channel setDisplayName:@"Import_150958_99z"];
[channel setDescription:@"Import_150958_99z"];
[channel setCreatedDateTime: "2020-03-14T11:22:17.067Z"];
NSError *error;
NSData *channelData = [channel getSerializedDataWithError:&error];
[urlRequest setHTTPBody:channelData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Channel channel = new Channel();
channel.additionalDataManager().put("@microsoft.graph.channelCreationMode", new JsonPrimitive("migration"));
channel.displayName = "Import_150958_99z";
channel.description = "Import_150958_99z";
channel.createdDateTime = OffsetDateTimeSerializer.deserialize("2020-03-14T11:22:17.067Z");
graphClient.teams("57fb72d0-d811-46f4-8947-305e6072eaa5").channels()
.buildRequest()
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewChannel()
displayName := "Import_150958_99z"
requestBody.SetDisplayName(&displayName)
description := "Import_150958_99z"
requestBody.SetDescription(&description)
createdDateTime, err := time.Parse(time.RFC3339, "2020-03-14T11:22:17.067Z")
requestBody.SetCreatedDateTime(&createdDateTime)
requestBody.SetAdditionalData(map[string]interface{}{
"@microsoft.graph.channelCreationMode": "migration",
}
teamId := "team-id"
result, err := graphClient.TeamsById(&teamId).Channels().Post(requestBody)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Import-Module Microsoft.Graph.Teams
$params = @{
"@microsoft.graph.channelCreationMode" = "migration"
DisplayName = "Import_150958_99z"
Description = "Import_150958_99z"
CreatedDateTime = [System.DateTime]::Parse("2020-03-14T11:22:17.067Z")
}
New-MgTeamChannel -TeamId $teamId -BodyParameter $params
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
O exemplo a seguir mostra a resposta. O cabeçalho Content-Location na resposta especifica o caminho para o canal que está sendo provisionado.
Depois de provisionado, esse canal pode ser usado para importar mensagens .
HTTP/1.1 201 Created
Location: /teams('57fb72d0-d811-46f4-8947-305e6072eaa5')/channels('19:4b6bed8d24574f6a9e436813cb2617d8@thread.tacv2')
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('57fb72d0-d811-46f4-8947-305e6072eaa5')/channels/$entity",
"id": "19:987c7a9fbe6447ccb3ea31bcded5c75c@thread.tacv2",
"createdDateTime": null,
"displayName": "Import_150958_99z",
"description": "Import_150958_99z",
"isFavoriteByDefault": null,
"email": null,
"webUrl": null,
"membershipType": null,
"moderationSettings": null
}
Exemplo 4: Criar um canal privado em nome do usuário usando o nome UPN
Solicitação
O exemplo a seguir mostra uma solicitação para criar um canal privado e adicionar um usuário como proprietário da equipe.
POST https://graph.microsoft.com/v1.0/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels
Content-type: application/json
{
"@odata.type": "#Microsoft.Graph.channel",
"membershipType": "private",
"displayName": "My First Private Channel",
"description": "This is my first private channels",
"members":
[
{
"@odata.type":"#microsoft.graph.aadUserConversationMember",
"user@odata.bind":"https://graph.microsoft.com/v1.0/users('jacob@contoso.com')",
"roles":["owner"]
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var channel = new Channel
{
MembershipType = ChannelMembershipType.Private,
DisplayName = "My First Private Channel",
Description = "This is my first private channels",
Members = new ChannelMembersCollectionPage()
{
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{"user@odata.bind", "https://graph.microsoft.com/v1.0/users('jacob@contoso.com')"}
}
}
}
};
await graphClient.Teams["{team-id}"].Channels
.Request()
.AddAsync(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
const channel = {
'@odata.type': '#Microsoft.Graph.channel',
membershipType: 'private',
displayName: 'My First Private Channel',
description: 'This is my first private channels',
members:
[
{
'@odata.type':'#microsoft.graph.aadUserConversationMember',
'user@odata.bind':'https://graph.microsoft.com/v1.0/users(\'jacob@contoso.com\')',
roles: ['owner']
}
]
};
await client.api('/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels')
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphChannel *channel = [[MSGraphChannel alloc] init];
[channel setMembershipType: [MSGraphChannelMembershipType private]];
[channel setDisplayName:@"My First Private Channel"];
[channel setDescription:@"This is my first private channels"];
NSMutableArray *membersList = [[NSMutableArray alloc] init];
MSGraphConversationMember *members = [[MSGraphConversationMember alloc] init];
NSMutableArray *rolesList = [[NSMutableArray alloc] init];
[rolesList addObject: @"owner"];
[members setRoles:rolesList];
[membersList addObject: members];
[channel setMembers:membersList];
NSError *error;
NSData *channelData = [channel getSerializedDataWithError:&error];
[urlRequest setHTTPBody:channelData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Channel channel = new Channel();
channel.membershipType = ChannelMembershipType.PRIVATE;
channel.displayName = "My First Private Channel";
channel.description = "This is my first private channels";
LinkedList<ConversationMember> membersList = new LinkedList<ConversationMember>();
AadUserConversationMember members = new AadUserConversationMember();
members.additionalDataManager().put("user@odata.bind", new JsonPrimitive("https://graph.microsoft.com/v1.0/users('jacob@contoso.com')"));
LinkedList<String> rolesList = new LinkedList<String>();
rolesList.add("owner");
members.roles = rolesList;
membersList.add(members);
ConversationMemberCollectionResponse conversationMemberCollectionResponse = new ConversationMemberCollectionResponse();
conversationMemberCollectionResponse.value = membersList;
ConversationMemberCollectionPage conversationMemberCollectionPage = new ConversationMemberCollectionPage(conversationMemberCollectionResponse, null);
channel.members = conversationMemberCollectionPage;
graphClient.teams("57fb72d0-d811-46f4-8947-305e6072eaa5").channels()
.buildRequest()
.post(channel);
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewChannel()
membershipType := "private"
requestBody.SetMembershipType(&membershipType)
displayName := "My First Private Channel"
requestBody.SetDisplayName(&displayName)
description := "This is my first private channels"
requestBody.SetDescription(&description)
requestBody.SetMembers( []ConversationMember {
msgraphsdk.NewConversationMember(),
SetRoles( []String {
"owner",
}
SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"user@odata.bind": "https://graph.microsoft.com/v1.0/users('jacob@contoso.com')",
}
}
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#Microsoft.Graph.channel",
}
teamId := "team-id"
result, err := graphClient.TeamsById(&teamId).Channels().Post(requestBody)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Import-Module Microsoft.Graph.Teams
$params = @{
"@odata.type" = "#Microsoft.Graph.channel"
MembershipType = "private"
DisplayName = "My First Private Channel"
Description = "This is my first private channels"
Members = @(
@{
"@odata.type" = "#microsoft.graph.aadUserConversationMember"
"User@odata.bind" = "https://graph.microsoft.com/v1.0/users('jacob@contoso.com')"
Roles = @(
"owner"
)
}
)
}
New-MgTeamChannel -TeamId $teamId -BodyParameter $params
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('57fb72d0-d811-46f4-8947-305e6072eaa5')/channels/$entity",
"id": "19:33b76eea88574bd1969dca37e2b7a819@thread.skype",
"displayName": "My First Private Channel",
"description": "This is my first private channels",
"isFavoriteByDefault": null,
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19:33b76eea88574bd1969dca37e2b7a819@thread.skype/My%20First%20Private%20Channel?groupId=57fb72d0-d811-46f4-8947-305e6072eaa5&tenantId=0fddfdc5-f319-491f-a514-be1bc1bf9ddc",
"membershipType": "private"
}