Eine der folgenden Berechtigungen ist erforderlich, um diese API aufzurufen. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie unter Berechtigungen.
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Hinweis: Die Berechtigung "Teamwork.Migrate.All" wird nur für Migration unterstützt.
Microsoft kann in Zukunft von Ihnen oder Ihren Kunden fordern, basierend auf der Menge der importierten Daten, zusätzliche Gebühren zu zahlen.
Hinweis: Mit ** markierte Berechtigungen werden nur aus Gründen der Abwärtskompatibilität unterstützt. Es wird empfohlen, Ihre Lösungen zu aktualisieren, sodass sie eine alternative Berechtigung verwenden, die in der vorherigen Tabelle aufgeführt ist, und diese Berechtigungen in Zukunft nicht mehr verwenden.
HTTP-Anforderung
POST /teams
Anforderungsheader
Kopfzeile
Wert
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json. Erforderlich.
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines team-Objekts an.
Antwort
Falls erfolgreich, gibt diese API eine 202 Accepted-Antwort mit einem Link zum teamsAsyncOperation zurück.
Beispiele
Beispiel 1: Delegierte Berechtigungen
Nachfolgend sehen Sie ein Beispiel für eine Mindestanforderung. Durch Auslassen anderer Eigenschaften verwendet der Client implizit die Standardwerte aus der vordefinierten Vorlage, die durch template angegeben wird.
POST https://graph.microsoft.com/v1.0/teams
Content-Type: application/json
{
"template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"displayName": "My Sample Team",
"description": "My Sample Team’s Description"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
DisplayName = "My Sample Team",
Description = "My Sample Team’s Description",
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Team team = new Team();
team.additionalDataManager().put("template@odata.bind", new JsonPrimitive("https://graph.microsoft.com/v1.0/teamsTemplates('standard')"));
team.displayName = "My Sample Team";
team.description = "My Sample Team’s Description";
graphClient.teams()
.buildRequest()
.post(team);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Team();
$requestBody->setDisplayName('My Sample Team');
$requestBody->setDescription('My Sample Team’s Description');
$additionalData = [
'template@odata.bind' => 'https://graph.microsoft.com/v1.0/teamsTemplates(\'standard\')',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->teams()->post($requestBody);
Im Folgenden sehen Sie ein Beispiel für eine Mindestanforderung unter Verwendung der Anwendungsberechtigungen. Durch Auslassen anderer Eigenschaften verwendet der Client implizit die Standardwerte aus der vordefinierten Vorlage, die durch template angegeben wird. Wenn Sie eine Anforderung mit Anwendungsberechtigungen erstellen, muss ein Benutzer in der members-Sammlung angegeben werden.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
DisplayName = "My Sample Team",
Description = "My Sample Team’s Description",
Members = new List<ConversationMember>
{
new ConversationMember
{
OdataType = "#microsoft.graph.aadUserConversationMember",
Roles = new List<string>
{
"owner",
},
AdditionalData = new Dictionary<string, object>
{
{
"user@odata.bind" , "https://graph.microsoft.com/v1.0/users('0040b377-61d8-43db-94f5-81374122dc7e')"
},
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);
Beispiel 3: Erstellen eines Teams mit mehreren Kanälen, installierten Apps und angehefteten Registerkarten unter Verwendung delegierter Berechtigungen
Im Folgenden sehen Sie eine Anforderung mit vollständiger Nutzlast. Der Client kann Werte in der Basisvorlage außer Kraft setzen und zu Elementen mit Arraywerten hinzufügen, soweit es die Validierungsregeln für specialization zulassen.
POST https://graph.microsoft.com/v1.0/teams
Content-Type: application/json
{
"template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"visibility": "Private",
"displayName": "Sample Engineering Team",
"description": "This is a sample engineering team, used to showcase the range of properties supported by this API",
"channels": [
{
"displayName": "Announcements 📢",
"isFavoriteByDefault": true,
"description": "This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements."
},
{
"displayName": "Training 🏋️",
"isFavoriteByDefault": true,
"description": "This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.",
"tabs": [
{
"teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')",
"displayName": "A Pinned Website",
"configuration": {
"contentUrl": "https://learn.microsoft.com/microsoftteams/microsoft-teams"
}
},
{
"teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')",
"displayName": "A Pinned YouTube Video",
"configuration": {
"contentUrl": "https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ",
"websiteUrl": "https://www.youtube.com/watch?v=X8krAMdGvCQ"
}
}
]
},
{
"displayName": "Planning 📅 ",
"description": "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.",
"isFavoriteByDefault": false
},
{
"displayName": "Issues and Feedback 🐞",
"description": "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu."
}
],
"memberSettings": {
"allowCreateUpdateChannels": true,
"allowDeleteChannels": true,
"allowAddRemoveApps": true,
"allowCreateUpdateRemoveTabs": true,
"allowCreateUpdateRemoveConnectors": true
},
"guestSettings": {
"allowCreateUpdateChannels": false,
"allowDeleteChannels": false
},
"funSettings": {
"allowGiphy": true,
"giphyContentRating": "Moderate",
"allowStickersAndMemes": true,
"allowCustomMemes": true
},
"messagingSettings": {
"allowUserEditMessages": true,
"allowUserDeleteMessages": true,
"allowOwnerDeleteMessages": true,
"allowTeamMentions": true,
"allowChannelMentions": true
},
"discoverySettings": {
"showInTeamsSearchAndSuggestions": true
},
"installedApps": [
{
"teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.vsts')"
},
{
"teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('1542629c-01b3-4a6d-8f76-1938b779e48d')"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
Visibility = TeamVisibilityType.Private,
DisplayName = "Sample Engineering Team",
Description = "This is a sample engineering team, used to showcase the range of properties supported by this API",
Channels = new List<Channel>
{
new Channel
{
DisplayName = "Announcements 📢",
IsFavoriteByDefault = true,
Description = "This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements.",
},
new Channel
{
DisplayName = "Training 🏋️",
IsFavoriteByDefault = true,
Description = "This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.",
Tabs = new List<TeamsTab>
{
new TeamsTab
{
DisplayName = "A Pinned Website",
Configuration = new TeamsTabConfiguration
{
ContentUrl = "https://learn.microsoft.com/microsoftteams/microsoft-teams",
},
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')"
},
},
},
new TeamsTab
{
DisplayName = "A Pinned YouTube Video",
Configuration = new TeamsTabConfiguration
{
ContentUrl = "https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ",
WebsiteUrl = "https://www.youtube.com/watch?v=X8krAMdGvCQ",
},
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')"
},
},
},
},
},
new Channel
{
DisplayName = "Planning 📅 ",
Description = "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.",
IsFavoriteByDefault = false,
},
new Channel
{
DisplayName = "Issues and Feedback 🐞",
Description = "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.",
},
},
MemberSettings = new TeamMemberSettings
{
AllowCreateUpdateChannels = true,
AllowDeleteChannels = true,
AllowAddRemoveApps = true,
AllowCreateUpdateRemoveTabs = true,
AllowCreateUpdateRemoveConnectors = true,
},
GuestSettings = new TeamGuestSettings
{
AllowCreateUpdateChannels = false,
AllowDeleteChannels = false,
},
FunSettings = new TeamFunSettings
{
AllowGiphy = true,
GiphyContentRating = GiphyRatingType.Moderate,
AllowStickersAndMemes = true,
AllowCustomMemes = true,
},
MessagingSettings = new TeamMessagingSettings
{
AllowUserEditMessages = true,
AllowUserDeleteMessages = true,
AllowOwnerDeleteMessages = true,
AllowTeamMentions = true,
AllowChannelMentions = true,
},
InstalledApps = new List<TeamsAppInstallation>
{
new TeamsAppInstallation
{
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.vsts')"
},
},
},
new TeamsAppInstallation
{
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('1542629c-01b3-4a6d-8f76-1938b779e48d')"
},
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
},
{
"discoverySettings" , new
{
ShowInTeamsSearchAndSuggestions = true,
}
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const team = {
'template@odata.bind': 'https://graph.microsoft.com/v1.0/teamsTemplates(\'standard\')',
visibility: 'Private',
displayName: 'Sample Engineering Team',
description: 'This is a sample engineering team, used to showcase the range of properties supported by this API',
channels: [
{
displayName: 'Announcements 📢',
isFavoriteByDefault: true,
description: 'This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements.'
},
{
displayName: 'Training 🏋️',
isFavoriteByDefault: true,
description: 'This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.',
tabs: [
{
'teamsApp@odata.bind': 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.web\')',
displayName: 'A Pinned Website',
configuration: {
contentUrl: 'https://learn.microsoft.com/microsoftteams/microsoft-teams'
}
},
{
'teamsApp@odata.bind': 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.youtube\')',
displayName: 'A Pinned YouTube Video',
configuration: {
contentUrl: 'https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ',
websiteUrl: 'https://www.youtube.com/watch?v=X8krAMdGvCQ'
}
}
]
},
{
displayName: 'Planning 📅 ',
description: 'This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.',
isFavoriteByDefault: false
},
{
displayName: 'Issues and Feedback 🐞',
description: 'This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.'
}
],
memberSettings: {
allowCreateUpdateChannels: true,
allowDeleteChannels: true,
allowAddRemoveApps: true,
allowCreateUpdateRemoveTabs: true,
allowCreateUpdateRemoveConnectors: true
},
guestSettings: {
allowCreateUpdateChannels: false,
allowDeleteChannels: false
},
funSettings: {
allowGiphy: true,
giphyContentRating: 'Moderate',
allowStickersAndMemes: true,
allowCustomMemes: true
},
messagingSettings: {
allowUserEditMessages: true,
allowUserDeleteMessages: true,
allowOwnerDeleteMessages: true,
allowTeamMentions: true,
allowChannelMentions: true
},
discoverySettings: {
showInTeamsSearchAndSuggestions: true
},
installedApps: [
{
'teamsApp@odata.bind': 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.vsts\')'
},
{
'teamsApp@odata.bind': 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'1542629c-01b3-4a6d-8f76-1938b779e48d\')'
}
]
};
await client.api('/teams')
.post(team);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Team();
$requestBody->setVisibility(new TeamVisibilityType('private'));
$requestBody->setDisplayName('Sample Engineering Team');
$requestBody->setDescription('This is a sample engineering team, used to showcase the range of properties supported by this API');
$channelsChannel1 = new Channel();
$channelsChannel1->setDisplayName('Announcements 📢');
$channelsChannel1->setIsFavoriteByDefault(true);
$channelsChannel1->setDescription('This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements.');
$channelsArray []= $channelsChannel1;
$channelsChannel2 = new Channel();
$channelsChannel2->setDisplayName('Training 🏋️');
$channelsChannel2->setIsFavoriteByDefault(true);
$channelsChannel2->setDescription('This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.');
$tabsTeamsTab1 = new TeamsTab();
$tabsTeamsTab1->setDisplayName('A Pinned Website');
$tabsTeamsTab1Configuration = new TeamsTabConfiguration();
$tabsTeamsTab1Configuration->setContentUrl('https://learn.microsoft.com/microsoftteams/microsoft-teams');
$tabsTeamsTab1->setConfiguration($tabsTeamsTab1Configuration);
$additionalData = [
'teamsApp@odata.bind' => 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.web\')',
];
$tabsTeamsTab1->setAdditionalData($additionalData);
$tabsArray []= $tabsTeamsTab1;
$tabsTeamsTab2 = new TeamsTab();
$tabsTeamsTab2->setDisplayName('A Pinned YouTube Video');
$tabsTeamsTab2Configuration = new TeamsTabConfiguration();
$tabsTeamsTab2Configuration->setContentUrl('https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ');
$tabsTeamsTab2Configuration->setWebsiteUrl('https://www.youtube.com/watch?v=X8krAMdGvCQ');
$tabsTeamsTab2->setConfiguration($tabsTeamsTab2Configuration);
$additionalData = [
'teamsApp@odata.bind' => 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.youtube\')',
];
$tabsTeamsTab2->setAdditionalData($additionalData);
$tabsArray []= $tabsTeamsTab2;
$channelsChannel2->setTabs($tabsArray);
$channelsArray []= $channelsChannel2;
$channelsChannel3 = new Channel();
$channelsChannel3->setDisplayName('Planning 📅 ');
$channelsChannel3->setDescription('This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.');
$channelsChannel3->setIsFavoriteByDefault(false);
$channelsArray []= $channelsChannel3;
$channelsChannel4 = new Channel();
$channelsChannel4->setDisplayName('Issues and Feedback 🐞');
$channelsChannel4->setDescription('This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.');
$channelsArray []= $channelsChannel4;
$requestBody->setChannels($channelsArray);
$memberSettings = new TeamMemberSettings();
$memberSettings->setAllowCreateUpdateChannels(true);
$memberSettings->setAllowDeleteChannels(true);
$memberSettings->setAllowAddRemoveApps(true);
$memberSettings->setAllowCreateUpdateRemoveTabs(true);
$memberSettings->setAllowCreateUpdateRemoveConnectors(true);
$requestBody->setMemberSettings($memberSettings);
$guestSettings = new TeamGuestSettings();
$guestSettings->setAllowCreateUpdateChannels(false);
$guestSettings->setAllowDeleteChannels(false);
$requestBody->setGuestSettings($guestSettings);
$funSettings = new TeamFunSettings();
$funSettings->setAllowGiphy(true);
$funSettings->setGiphyContentRating(new GiphyRatingType('moderate'));
$funSettings->setAllowStickersAndMemes(true);
$funSettings->setAllowCustomMemes(true);
$requestBody->setFunSettings($funSettings);
$messagingSettings = new TeamMessagingSettings();
$messagingSettings->setAllowUserEditMessages(true);
$messagingSettings->setAllowUserDeleteMessages(true);
$messagingSettings->setAllowOwnerDeleteMessages(true);
$messagingSettings->setAllowTeamMentions(true);
$messagingSettings->setAllowChannelMentions(true);
$requestBody->setMessagingSettings($messagingSettings);
$installedAppsTeamsAppInstallation1 = new TeamsAppInstallation();
$additionalData = [
'teamsApp@odata.bind' => 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.vsts\')',
];
$installedAppsTeamsAppInstallation1->setAdditionalData($additionalData);
$installedAppsArray []= $installedAppsTeamsAppInstallation1;
$installedAppsTeamsAppInstallation2 = new TeamsAppInstallation();
$additionalData = [
'teamsApp@odata.bind' => 'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'1542629c-01b3-4a6d-8f76-1938b779e48d\')',
];
$installedAppsTeamsAppInstallation2->setAdditionalData($additionalData);
$installedAppsArray []= $installedAppsTeamsAppInstallation2;
$requestBody->setInstalledApps($installedAppsArray);
$additionalData = [
'template@odata.bind' => 'https://graph.microsoft.com/v1.0/teamsTemplates(\'standard\')',
'discoverySettings' => $requestBody = new DiscoverySettings();
$requestBody->setShowInTeamsSearchAndSuggestions(true);
$requestBody->setDiscoverySettings($discoverySettings);
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->teams()->post($requestBody);
Import-Module Microsoft.Graph.Teams
$params = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
visibility = "Private"
displayName = "Sample Engineering Team"
description = "This is a sample engineering team, used to showcase the range of properties supported by this API"
channels = @(
@{
displayName = "Announcements 📢"
isFavoriteByDefault = $true
description = "This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements."
}
@{
displayName = "Training 🏋️"
isFavoriteByDefault = $true
description = "This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs."
tabs = @(
@{
"teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')"
displayName = "A Pinned Website"
configuration = @{
contentUrl = "https://learn.microsoft.com/microsoftteams/microsoft-teams"
}
}
@{
"teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')"
displayName = "A Pinned YouTube Video"
configuration = @{
contentUrl = "https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ"
websiteUrl = "https://www.youtube.com/watch?v=X8krAMdGvCQ"
}
}
)
}
@{
displayName = "Planning 📅 "
description = "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu."
isFavoriteByDefault = $false
}
@{
displayName = "Issues and Feedback 🐞"
description = "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu."
}
)
memberSettings = @{
allowCreateUpdateChannels = $true
allowDeleteChannels = $true
allowAddRemoveApps = $true
allowCreateUpdateRemoveTabs = $true
allowCreateUpdateRemoveConnectors = $true
}
guestSettings = @{
allowCreateUpdateChannels = $false
allowDeleteChannels = $false
}
funSettings = @{
allowGiphy = $true
giphyContentRating = "Moderate"
allowStickersAndMemes = $true
allowCustomMemes = $true
}
messagingSettings = @{
allowUserEditMessages = $true
allowUserDeleteMessages = $true
allowOwnerDeleteMessages = $true
allowTeamMentions = $true
allowChannelMentions = $true
}
installedApps = @(
@{
"teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.vsts')"
}
@{
"teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('1542629c-01b3-4a6d-8f76-1938b779e48d')"
}
)
}
New-MgTeam -BodyParameter $params
Beispiel 4: Erstellen eines Teams aus einer Gruppe
Das folgende Beispiel zeigt, wie Sie ein neues Team aus einer Gruppe erstellen, wenn Sie eine groupId haben.
Ein paar Dinge, die Sie zu diesem Aufruf wissen sollten:
Damit ein Team erstellt werden kann, muss die Gruppe, aus der Sie es erstellen, mindestens einen Besitzer haben.
Das erstellte Team erbt Anzeigename, Sichtbarkeit, Spezialisierung und Mitglieder der Gruppe. Daher wird beim Ausführen dieses Aufrufs mit der group@odata.bind -Eigenschaft beim Einschließen von team displayName, visibility, spezialisierung oder members@odata.bind eigenschaften ein Fehler zurückgegeben.
Wenn die Gruppe vor weniger als 15 Minuten erstellt wurde, führt der Aufruf zum Erstellen eines Teams möglicherweise zu einem Fehler 404 aufgrund von Verzögerungen bei der Replikation. Wir empfehlen Ihnen, den Aufruf zum Erstellen des Teams drei Mal mit einer Verzögerung von 10 Sekunden zwischen den Aufrufen zu wiederholen.
POST https://graph.microsoft.com/v1.0/teams
Content-Type: application/json
{
"template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"group@odata.bind": "https://graph.microsoft.com/v1.0/groups('71392b2f-1765-406e-86af-5907d9bdb2ab')"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
},
{
"group@odata.bind" , "https://graph.microsoft.com/v1.0/groups('71392b2f-1765-406e-86af-5907d9bdb2ab')"
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Team team = new Team();
team.additionalDataManager().put("template@odata.bind", new JsonPrimitive("https://graph.microsoft.com/v1.0/teamsTemplates('standard')"));
team.additionalDataManager().put("group@odata.bind", new JsonPrimitive("https://graph.microsoft.com/v1.0/groups('71392b2f-1765-406e-86af-5907d9bdb2ab')"));
graphClient.teams()
.buildRequest()
.post(team);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Team();
$additionalData = [
'template@odata.bind' => 'https://graph.microsoft.com/v1.0/teamsTemplates(\'standard\')',
'group@odata.bind' => 'https://graph.microsoft.com/v1.0/groups(\'71392b2f-1765-406e-86af-5907d9bdb2ab\')',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->teams()->post($requestBody);
Beispiel 5: Erstellen eines Teams mit mehreren Kanälen, installierten Apps und angehefteten Registerkarten aus einer Gruppe
Im Folgenden finden Sie eine Anforderung zum Konvertieren einer vorhandenen Gruppe mit erweiterten Eigenschaften, die das Team mit mehreren Kanälen, installierten Apps und angehefteten Registerkarten erstellt.
Weitere Informationen zu unterstützten Basisvorlagentypen und erweiterten Eigenschaften finden Sie unter Erste Schritte mit Teams-Vorlagen.
Beispiel 6: Erstellen eines Teams mit einem nicht standardmäßigen Basisvorlagentyp
Basisvorlagentypen sind spezielle Vorlagen, die Microsoft für bestimmte Branchen erstellt. Diese Basisvorlagen enthalten häufig proprietäre Apps, die nicht im Store verfügbar sind, und Teameigenschaften, die noch nicht separat in Microsoft Teams-Vorlagen unterstützt werden.
Um ein Team aus einer nicht standardmäßigen Basisvorlage zu erstellen, sollten Sie die template@odata.bind-Eigenschaft im Anforderungstext aus standard verwenden, um auf die spezifische Basisvorlage zu zeige, die Sie erstellen möchten.
POST https://graph.microsoft.com/v1.0/teams
Content-Type: application/json
{
"template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')",
"displayName": "My Class Team",
"description": "My Class Team’s Description"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
DisplayName = "My Class Team",
Description = "My Class Team’s Description",
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Team team = new Team();
team.additionalDataManager().put("template@odata.bind", new JsonPrimitive("https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"));
team.displayName = "My Class Team";
team.description = "My Class Team’s Description";
graphClient.teams()
.buildRequest()
.post(team);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Team();
$requestBody->setDisplayName('My Class Team');
$requestBody->setDescription('My Class Team’s Description');
$additionalData = [
'template@odata.bind' => 'https://graph.microsoft.com/v1.0/teamsTemplates(\'educationClass\')',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->teams()->post($requestBody);
Beispiel 7: Erstellen eines Teams mit einem nicht standardmäßigen Basisvorlagentyp mit erweiterten Eigenschaften
Basisvorlagentypen können mit zusätzlichen Eigenschaften erweitert werden, sodass Sie auf einer vorhandenen Basisvorlage mit zusätzlichen Teameinstellungen, Kanälen, Apps oder Registerkarten aufbauen können.
Weitere Informationen zu unterstützten Basisvorlagentypen und erweiterten Eigenschaften finden Sie unter Erste Schritte mit Teams-Vorlagen.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
DisplayName = "My Class Team",
Description = "My Class Team’s Description",
Channels = new List<Channel>
{
new Channel
{
DisplayName = "Class Announcements 📢",
IsFavoriteByDefault = true,
},
new Channel
{
DisplayName = "Homework 🏋️",
IsFavoriteByDefault = true,
},
},
MemberSettings = new TeamMemberSettings
{
AllowCreateUpdateChannels = false,
AllowDeleteChannels = false,
AllowAddRemoveApps = false,
AllowCreateUpdateRemoveTabs = false,
AllowCreateUpdateRemoveConnectors = false,
},
InstalledApps = new List<TeamsAppInstallation>
{
new TeamsAppInstallation
{
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.vsts')"
},
},
},
new TeamsAppInstallation
{
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('1542629c-01b3-4a6d-8f76-1938b779e48d')"
},
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);
Beispiel 8: Erstellen eines Teams im Migrationsmodus
Anforderung
Das folgende Beispiel zeigt, wie Sie ein Team für importierte Nachrichten erstellen.
Hinweis: Microsoft kann in Zukunft von Ihnen oder Ihren Kunden fordern, basierend auf der Menge der importierten Daten, zusätzliche Gebühren zu zahlen.
Hinweis: Teams, die im Migrationsmodus erstellt wurden, unterstützen nur die standard-Vorlage.
POST https://graph.microsoft.com/v1.0/teams
Content-Type: application/json
{
"@microsoft.graph.teamCreationMode": "migration",
"template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"displayName": "My Sample Team",
"description": "My Sample Team’s Description",
"createdDateTime": "2020-03-14T11:22:17.067Z"
}
Wenn die Anforderung nicht erfolgreich ist, gibt diese Methode einen 400 Bad Request Antwortcode zurück.
400 Bad Request
Die Folgenden sind häufige Ursachen für diese Antwort:
createdDateTime ist in der Zukunft festgelegt.
createdDateTime ist ordnungsgemäß angegeben, aber das teamCreationMode Instanz-Attribut fehlt oder ist auf einen ungültigen Wert festgelegt.
Beispiel 9: Anwendungsberechtigungen unter Verwendung des Benutzerprinzipalnamens
Im Folgenden sehen Sie ein Beispiel für eine Mindestanforderung unter Verwendung der Anwendungsberechtigungen. Durch Auslassen anderer Eigenschaften verwendet der Client implizit die Standardwerte aus der vordefinierten Vorlage, die durch template angegeben wird. Wenn Sie eine Anforderung mit Anwendungsberechtigungen erstellen, muss ein Benutzer in der members-Sammlung angegeben werden.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Team
{
DisplayName = "My Sample Team",
Description = "My Sample Team’s Description",
Members = new List<ConversationMember>
{
new ConversationMember
{
OdataType = "#microsoft.graph.aadUserConversationMember",
Roles = new List<string>
{
"owner",
},
AdditionalData = new Dictionary<string, object>
{
{
"user@odata.bind" , "https://graph.microsoft.com/v1.0/users('jacob@contoso.com')"
},
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"template@odata.bind" , "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
},
},
};
var result = await graphClient.Teams.PostAsync(requestBody);