Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Swift 3,4,5...) Microsoft Teams - Create Team (complex request)Create a team with multiple channels, installed apps, and pinned tabs using delegated permissions For more information, see https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0&tabs=http#example-3-create-a-team-with-multiple-channels-installed-apps-and-pinned-tabs-using-delegated-permissions
func chilkatTest() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let http = CkoHttp()! var success: Bool // Build the following HTTP request: // 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')", // "name": "A Pinned Website", // "configuration": { // "contentUrl": "https://docs.microsoft.com/microsoftteams/microsoft-teams" // } // }, // { // "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')", // "name": "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')" // } // ] // } // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON let json = CkoJsonObject()! json.update("\"template@odata.bind\"", value: "https://graph.microsoft.com/v1.0/teamsTemplates('standard')") json.update("visibility", value: "Private") json.update("displayName", value: "Sample Engineering Team") json.update("description", value: "This is a sample engineering team, used to showcase the range of properties supported by this API") json.update("channels[0].displayName", value: "Announcements") json.updateBool("channels[0].isFavoriteByDefault", value: true) json.update("channels[0].description", value: "This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements.") json.update("channels[1].displayName", value: "Training") json.updateBool("channels[1].isFavoriteByDefault", value: true) json.update("channels[1].description", value: "This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.") json.update("channels[1].tabs[0].\"teamsApp@odata.bind\"", value: "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')") json.update("channels[1].tabs[0].name", value: "A Pinned Website") json.update("channels[1].tabs[0].configuration.contentUrl", value: "https://docs.microsoft.com/microsoftteams/microsoft-teams") json.update("channels[1].tabs[1].\"teamsApp@odata.bind\"", value: "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')") json.update("channels[1].tabs[1].name", value: "A Pinned YouTube Video") json.update("channels[1].tabs[1].configuration.contentUrl", value: "https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ") json.update("channels[1].tabs[1].configuration.websiteUrl", value: "https://www.youtube.com/watch?v=X8krAMdGvCQ") json.update("channels[2].displayName", value: "Planning") json.update("channels[2].description", value: "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.") json.updateBool("channels[2].isFavoriteByDefault", value: false) json.update("channels[3].displayName", value: "Issues and Feedback") json.update("channels[3].description", value: "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.") json.updateBool("memberSettings.allowCreateUpdateChannels", value: true) json.updateBool("memberSettings.allowDeleteChannels", value: true) json.updateBool("memberSettings.allowAddRemoveApps", value: true) json.updateBool("memberSettings.allowCreateUpdateRemoveTabs", value: true) json.updateBool("memberSettings.allowCreateUpdateRemoveConnectors", value: true) json.updateBool("guestSettings.allowCreateUpdateChannels", value: false) json.updateBool("guestSettings.allowDeleteChannels", value: false) json.updateBool("funSettings.allowGiphy", value: true) json.update("funSettings.giphyContentRating", value: "Moderate") json.updateBool("funSettings.allowStickersAndMemes", value: true) json.updateBool("funSettings.allowCustomMemes", value: true) json.updateBool("messagingSettings.allowUserEditMessages", value: true) json.updateBool("messagingSettings.allowUserDeleteMessages", value: true) json.updateBool("messagingSettings.allowOwnerDeleteMessages", value: true) json.updateBool("messagingSettings.allowTeamMentions", value: true) json.updateBool("messagingSettings.allowChannelMentions", value: true) json.updateBool("discoverySettings.showInTeamsSearchAndSuggestions", value: true) json.update("installedApps[0].\"teamsApp@odata.bind\"", value: "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.vsts')") json.update("installedApps[1].\"teamsApp@odata.bind\"", value: "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('1542629c-01b3-4a6d-8f76-1938b779e48d')") http.setRequestHeader("Content-type", value: "application/json") // Adds the "Authorization: Bearer ACCESS_TOKEN" header. http.authToken = "ACCESS_TOKEN" var resp: CkoHttpResponse? = http.postJson3("https://graph.microsoft.com/v1.0/teams", contentType: "application/json", json: json) if http.lastMethodSuccess == false { print("\(http.lastErrorText!)") return } // A successful response is indicated by a 202 response status code and an empty response body. print("Response Status Code: \(resp!.statusCode.intValue)") print("Response Body:") print("\(resp!.bodyStr!)") if resp!.statusCode.intValue >= 400 { print("Response Header:") print("\(resp!.header!)") print("Failed.") } resp = nil } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.