SOLVED

Create Teams with Rest API failing.

%3CLINGO-SUB%20id%3D%22lingo-sub-481157%22%20slang%3D%22en-US%22%3ECreate%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-481157%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3EI'm%20following%20this%20article%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fget-started-with-teams-templates%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fget-started-with-teams-templates%3C%2FA%3E)%20%26amp%3B%20this%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fteam-post%3Fview%3Dgraph-rest-beta%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fteam-post%3Fview%3Dgraph-rest-beta%3C%2FA%3E)%20and%20calling%20the%20following%20bit%20of%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInvoke-RestMethod%20%60%3CBR%20%2F%3E-Uri%20%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%3C%2FA%3E%20%60%3CBR%20%2F%3E-Body%20%24bodycreateteams%20%60%3CBR%20%2F%3E-ContentType%20%22application%2Fjson%22%20%60%3CBR%20%2F%3E-Headers%20%40%7BAuthorization%20%3D%20%22Bearer%20%24accesstoken%22%7D%20%60%3CBR%20%2F%3E-Method%20Post%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20get%20the%20error%3A%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3A%5CCreateTeam.ps1%20%3A%20ERROR%20occurred%3A%20The%20remote%20server%20returned%20an%20error%3A%20(400)%3CBR%20%2F%3EBad%20Request.%3CBR%20%2F%3EResponse%20body%3A%3CBR%20%2F%3EThe%20remote%20server%20returned%20an%20error%3A%20(400)%20Bad%20Request.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJson%20body%26nbsp%3B%20(%24bodycreateteams)%20is%3A%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22template%40odata.bind%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FteamsTemplates('educationClass%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FteamsTemplates('educationClass%3C%2FA%3E')%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22TeamDispName%22%2C%3CBR%20%2F%3E%22description%22%3A%20%22This%20is%20a%20EducationClass%20Template%20Teamsite%22%2C%3CBR%20%2F%3E%22visibility%22%3A%20%22Private%22%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20substitue%20%22educationClass%22%20for%20retailStore%2C%20educationStaff%2C%20healthcareWard%20etc%20it%20works%20fine.%20No%20errors.%26nbsp%3BI%20have%20done%20a%20try%20catch%20around%20the%20Invoke-RestMethod%20and%20the%20message%20displayed%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eerror%3CBR%20%2F%3E-----%3CBR%20%2F%3E%40%7Bcode%3DBadRequest%3B%20message%3DFailed%20to%20execute%20Templates%20backend%20request%20CreateTeamFromTemplateRequest.%20Request%20Url%3A%20%3CA%20href%3D%22https%3A%2F%2Fteams.m%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fteams.m%3C%2FA%3E...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20anyone%3F%20I've%20also%20noticed%20that%20when%20I%20use%20the%20template%20educationProfessionalLearningCommunity%20it%20just%20creates%20a%20team%20with%20a%20standard%20template.%3C%2FP%3E%3CP%3EThanks%3CBR%20%2F%3EIswar%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-683040%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-683040%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F323858%22%20target%3D%22_blank%22%3E%40Iswar2019%3C%2FA%3E%26nbsp%3B-%26nbsp%3BAre%20you%20creating%20this%20team%20on%20Education%20tenant%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-683061%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-683061%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F79135%22%20target%3D%22_blank%22%3E%40Wajeed%20Hanif%20Shaik%3C%2FA%3E%26nbsp%3Bno%20I%20have%20a%20trial%20O365%20tenant.%20I%20don't%20have%20an%20education%20tenant.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIswar%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-689915%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-689915%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F323858%22%20target%3D%22_blank%22%3E%40Iswar2019%3C%2FA%3E%20Could%20you%20please%20try%20this%20payload%20and%20check%20if%20that%20helps%3A%3C%2FP%3E%0A%3CDIV%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%7B%3CBR%20%2F%3E%22template%40odata.bind%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FteamsTemplates('educationClass%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FteamsTemplates('educationClass%3C%2FA%3E')%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22TeamDispName%22%2C%3CBR%20%2F%3E%22description%22%3A%20%22This%20is%20a%20EducationClass%20Template%20Teamsite%22%2C%3C%2FFONT%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%7D%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-690094%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-690094%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F359599%22%20target%3D%22_blank%22%3E%40Gousia_Begum%3C%2FA%3E%26nbsp%3BThank%20you%20that%20works.%20I%20guess%20as%20its%20an%20education%20class%20template%2C%20you%20would%20not%20want%20it%20as%20a%20private%20team.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIswar%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2155035%22%20slang%3D%22en-US%22%3ECreate%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2155035%22%20slang%3D%22en-US%22%3E%3CP%3Etrying%20creating%20team%20from%20API%3C%2FP%3E%3CP%3EUrl%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%3C%2FA%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22template%40odata.bind%22%3A%20%20%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2FteamsTemplates('standard')%22%2C%0A%20%20%20%20%22displayName%22%3A%20%20%22My%20Sample%20Team%22%2C%0A%20%20%20%20%22description%22%3A%20%20%22My%20Sample%20Team%E2%80%99s%20Description%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3BGetting%20error%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22error%22%3A%20%7B%0A%20%20%20%20%22code%22%3A%20%22NotFound%22%2C%0A%20%20%20%20%22message%22%3A%20%22Failed%20to%20execute%20Templates%20backend%20request%20CreateTeamFromTemplateRequest.%20Request%20Url%3A%20https%3A%2F%2Fteams.microsoft.com%2Ffabric%2Ftemplates%2Fapi%2Fteam%2C%20Request%20Method%3A%20POST%2C%20Response%20Status%20Code%3A%20NotFound%2C%20Response%20Headers%3A%20Strict-Transport-Security%3A%20max-age%3D2592000%5Cr%5Cnx-operationid%3A%20af9b43f0011aa34bafb0400804c45201%5Cr%5Cnx-telemetryid%3A%20%7Caf9b43f0011aa34bafb0400804c45201.38f8d9fe_1.%5Cr%5CnX-MSEdge-Ref%3A%20Ref%20A%3A%206A658B600FBD4B62A0AD3C550C0F7AAD%20Ref%20B%3A%20AM3EDGE1013%20Ref%20C%3A%202020-03-03T09%3A36%3A24Z%5Cr%5CnDate%3A%20Tue%2C%2003%20Mar%202020%2009%3A36%3A24%20GMT%5Cr%5Cn%2C%20ErrorMessage%20%3A%20%7B%5C%22errors%5C%22%3A%5B%7B%5C%22message%5C%22%3A%5C%22Failed%20to%20execute%20request%20for%20MiddleTier%20CreateTeamS2SAsync.%20Status%20code%3A%20NotFound.%5C%22%7D%5D%2C%5C%22operationId%5C%22%3A%5C%22af9b43f0011aa34bafb0400804c45201%5C%22%7D%22%2C%0A%20%20%20%20%22innerError%22%3A%20%7B%0A%20%20%20%20%20%20%22request-id%22%3A%20%22ef003a99-2268-4e9c-903b-9af5239c971a%22%2C%0A%20%20%20%20%20%20%22date%22%3A%20%222020-03-03T09%3A36%3A24%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2157920%22%20slang%3D%22fr-FR%22%3ERe%3A%20Create%20Teams%20with%20Rest%20API%20failing.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2157920%22%20slang%3D%22fr-FR%22%3E%3CP%3EHello%2C%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F970500%22%20target%3D%22_blank%22%3E%40robinsinghescalon%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20correct%20syntax%3A%3C%2FP%3E%3CP%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22hljs-attr%22%3E%22template%40odata.bind%22%3A%3C%2FSPAN%3E%3CSPAN%3E%20%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2FteamsTemplates('standard%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2FteamsTemplates%20('standard')%22%3C%2FA%3E%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22hljs-attr%22%3E%22displayName%22%3A%3C%2FSPAN%3E%3CSPAN%3E%20%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22My%20Sample%20Team%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22hljs-attr%22%3E%22description%22%3A%3C%2FSPAN%3E%3CSPAN%3E%20%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22My%20Sample%20Team's%20Description%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi

I'm following this article (https://docs.microsoft.com/en-us/microsoftteams/get-started-with-teams-templates) & this (https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-beta) and calling the following bit of code:

 

Invoke-RestMethod `
-Uri https://graph.microsoft.com/beta/teams `
-Body $bodycreateteams `
-ContentType "application/json" `
-Headers @{Authorization = "Bearer $accesstoken"} `
-Method Post


I get the error:


:\CreateTeam.ps1 : ERROR occurred: The remote server returned an error: (400)
Bad Request.
Response body:
The remote server returned an error: (400) Bad Request.
At line:1 char:1

 

Json body  ($bodycreateteams) is:
{
"template@odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('educationClass')",
"displayName": "TeamDispName",
"description": "This is a EducationClass Template Teamsite",
"visibility": "Private"
}

 

When I substitue "educationClass" for retailStore, educationStaff, healthcareWard etc it works fine. No errors. I have done a try catch around the Invoke-RestMethod and the message displayed is:

 

error
-----
@{code=BadRequest; message=Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.m...

 

Any ideas anyone? I've also noticed that when I use the template educationProfessionalLearningCommunity it just creates a team with a standard template.

Thanks
Iswar

6 Replies

@Iswar2019 - Are you creating this team on Education tenant?

Hi @Wajeed-MSFT no I have a trial O365 tenant. I don't have an education tenant. 

 

Iswar

best response confirmed by Iswar2019 (Occasional Contributor)
Solution

@Iswar2019 Could you please try this payload and check if that helps:

{
"template@odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('educationClass')",
"displayName": "TeamDispName",
"description": "This is a EducationClass Template Teamsite",
}

@Gousia_Begum Thank you that works. I guess as its an education class template, you would not want it as a private team.

 

Iswar

trying creating team from API

Url: https://graph.microsoft.com/beta/teams

{
    "template@odata.bind":  "https://graph.microsoft.com/beta/teamsTemplates('standard')",
    "displayName":  "My Sample Team",
    "description":  "My Sample Team’s Description"
}

 Getting error

{
  "error": {
    "code": "NotFound",
    "message": "Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/templates/api/team, Request Method: POST, Response Status Code: NotFound, Response Headers: Strict-Transport-Security: max-age=2592000\r\nx-operationid: af9b43f0011aa34bafb0400804c45201\r\nx-telemetryid: |af9b43f0011aa34bafb0400804c45201.38f8d9fe_1.\r\nX-MSEdge-Ref: Ref A: 6A658B600FBD4B62A0AD3C550C0F7AAD Ref B: AM3EDGE1013 Ref C: 2020-03-03T09:36:24Z\r\nDate: Tue, 03 Mar 2020 09:36:24 GMT\r\n, ErrorMessage : {\"errors\":[{\"message\":\"Failed to execute request for MiddleTier CreateTeamS2SAsync. Status code: NotFound.\"}],\"operationId\":\"af9b43f0011aa34bafb0400804c45201\"}",
    "innerError": {
      "request-id": "ef003a99-2268-4e9c-903b-9af5239c971a",
      "date": "2020-03-03T09:36:24"
    }
  }
}

Hello,@robinsinghescalon 

 The correct syntax :

{

"template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",

"displayName": "My Sample Team",

"description": "My Sample Team’s Description"

}