question

JarbasHorst-2023 avatar image
1 Vote"
JarbasHorst-2023 asked ·

Broken POST v1.0/teams Microsoft Graph API

We use the Microsoft Graph API "POST teams/v1.0" to create Microsoft Teams team programmatically. This endpoint allows the creation of teams with predefined content such as settings, apps, channels, and tabs. However, we started facing on Feb 19th 2021 issues when trying to create a team with predefined tabs. The problem can be easily reproduced in Microsoft Graph Explorer. This is what the sample request I am using looks like. I used the sample provided in this documentation: https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0&tabs=http

 POST https://graph.microsoft.com/v1.0/teams
    
 {
     "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://docs.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')"
         }
     ]
 }

This is what the error response includes:

 {
    "error":{
       "code":"BadRequest",
       "message":"Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/emea/templates/api/team, Request Method: POST, Response Status Code: BadRequest, Response Headers: Strict-Transport-Security: max-age=2592000x-operationid: 32e057e44a0d6f4db6573946dc15fcfdx-telemetryid: 00-32e057e44a0d6f4db6573946dc15fcfd-20ade0692a92db46-00X-MSEdge-Ref: Ref A: 8AECC984E039443AB1E83EF82CD13757 Ref B: DB3EDGE0719 Ref C: 2021-02-20T07:00:06ZDate: Sat, 20 Feb 2021 07:00:06 GMT, ErrorMessage : {\"errors\":[{\"message\":\"Tabs with duplicate DisplayName are not allowed.\",\"errorCode\":\"Unknown\"},{\"message\":\"'Channel Name' must not be empty.\",\"errorCode\":\"Unknown\"},{\"message\":\"'Channel Name' should not be empty.\",\"errorCode\":\"Unknown\"},{\"message\":\"'Channel Name' must not be empty.\",\"errorCode\":\"Unknown\"},{\"message\":\"'Channel Name' should not be empty.\",\"errorCode\":\"Unknown\"}],\"operationId\":\"32e057e44a0d6f4db6573946dc15fcfd\"}",
       "innerError":{
          "date":"2021-02-20T07:00:06",
          "request-id":"7cb1cac4-9618-4ea6-baf0-9c415ad4a20c",
          "client-request-id":"146e1b6f-49ed-91ed-82c1-1691a5ca21ad"
       }
    }
 }

If the JSON object doesn't contain any tab configuration, the POST v1.0/teams endpoint works correctly. Here the test scenarios we covered:

  • POST beta/teams API

  • POST v1.0/teams API

  • delegated permission

  • application permission

office-teams-app-devmicrosoft-graph-teamwork
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JarbasHorst-2023, Could you please confirm on the Tabs, Channels, Installed Apps bind data are updated with your respective app configurations.

0 Votes 0 ·

Hi @JarbasHorst-2023, any updates on the issue?

0 Votes 0 ·
MallipriyaMSFT-6171 avatar image
0 Votes"
MallipriyaMSFT-6171 answered ·

To Create a team with multiple channels, installed apps, and pinned tabs using delegated permissions, you need to

  1. Call GET https://graph.microsoft.com/v1.0/appCatalogs/teamsApps

  2. Take the AppID of the respective app available in appcatalog that you want to install to the new Team
    being created.

  3. Replace with the AppID in the request body of the request mentioned in the document.
    "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('{App ID}')"

  4. The Team gets created with the respective channels and Apps.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Danstan avatar image
0 Votes"
Danstan answered ·

@JarbasHorst-2023 This issue was because of the tabs and was fixed earlier this week and should now work with your payload. Only note that that both name and displayName on the tabs will work but the documented property is displayName.

See the details in this related thread


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.