Microsoft-graph-docs: Example 4: Create a team from group EducationClass

Created on 26 Aug 2019  Â·  6Comments  Â·  Source: microsoftgraph/microsoft-graph-docs

I've tried Example 4: Create a team from group but get the following error :
Team with template 'educationClass' can not be provisioned using a group which does not belong to a class.
I've tried creating the group via https://docs.microsoft.com/en-us/graph/api/group-post-groups?view=graph-rest-beta&tabs=http and then running example 4 and get this error.

I've also tried creating the group via this method https://docs.microsoft.com/en-us/graph/api/educationroot-post-classes?view=graph-rest-beta&tabs=http and still get the same error


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

teams product TACO

Most helpful comment

I would like to confirm this: Creating an educationClass first via the "Create educationClass" POST call to /education/classes still does not let me POST a Team to that group later. The error still says "Team with template \'educationClass\' can not be provisioned using a group which does not belong to a class."

Is this intentional ?

All 6 comments

I would like to confirm this: Creating an educationClass first via the "Create educationClass" POST call to /education/classes still does not let me POST a Team to that group later. The error still says "Team with template \'educationClass\' can not be provisioned using a group which does not belong to a class."

Is this intentional ?

It doesn't seem to work with binding to the standard groups API or the endpoint for retrieving the linked group from an educationClass. I got it working by creating the educationClass, using /education/classes/{id}/group to retrieve the group object, then feeding the group object itself into the /teams POST request. For example, here's what I'm sending in that POST request:
{
"displayName": DISPLAYNAME,
"[email protected]": "https://graph.microsoft.com/beta/teamsTemplates('TEMPLATE')",
"[email protected]": ["https://graph.microsoft.com/beta/users/OWNER_ID"],
"group": GROUP_OBJECT
}

@ehussey can you share full code of it ?
Trying what you said , i get

Request

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

Body

{ "displayName": "test19082020", "[email protected]": "https://graph.microsoft.com/beta/teamsTemplates('educationClass')", "[email protected]": ["https://graph.microsoft.com/beta/users/[email protected]"], "group": { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups/$entity", "id": "ea61be68-cf0f-4361-893b-3a74ae250853", "deletedDateTime": null, "classification": null, "createdDateTime": "2020-08-19T07:52:49Z", "creationOptions": [ "Team", "ExchangeProvisioningFlags:3422" ], "description": "test19082020", "displayName": "test19082020", "expirationDateTime": null, "groupTypes": [ "Unified" ], "isAssignableToRole": null, "mail": "[email protected]", "mailEnabled": true, "mailNickname": "test19082020", "membershipRule": null, "membershipRuleProcessingState": null, "onPremisesDomainName": null, "onPremisesLastSyncDateTime": null, "onPremisesNetBiosName": null, "onPremisesSamAccountName": null, "onPremisesSecurityIdentifier": null, "onPremisesSyncEnabled": null, "preferredDataLocation": null, "preferredLanguage": null, "proxyAddresses": [ "SMTP:[email protected]" ], "renewedDateTime": "2020-08-19T07:52:49Z", "resourceBehaviorOptions": [ "SubscriptionDisabled", "SharePointMemberReadonly", "CalendarMemberReadOnly", "WelcomeEmailDisabled", "SubscribeNewGroupMembers", "HideGroupInOutlook", "ConnectorsDisabled", "AllowOnlyMembersToPost" ], "resourceProvisioningOptions": [ "Team" ], "securityEnabled": false, "securityIdentifier": "S-1-12-1-3932274280-1130483471-1949973385-1393042862", "theme": null, "visibility": "HiddenMembership", "extension_fe2174665583431c953114ff7268b7b3_Education_CreatedByUserId": "a9db57db-abbe-4599-a1a5-d8c6dcea7177", "extension_fe2174665583431c953114ff7268b7b3_Education_CreatedByAppId": "caaaf64c-8f20-4ab5-aee1-04fe11272b68", "extension_fe2174665583431c953114ff7268b7b3_Education_ObjectType": "Section", "onPremisesProvisioningErrors": [] } }

ERROR I GET


{
    "error": {
        "code": "BadRequest",
        "message": "Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/templates/api/team, Request Method: POST, Response Status Code: BadRequest, Response Headers: Strict-Transport-Security: max-age=2592000\r\nx-operationid: 61a89e916cb8eb41a944101827872907\r\nx-telemetryid: |61a89e916cb8eb41a944101827872907.b0ba4e9e_1.\r\nX-MSEdge-Ref: Ref A: AE610EB406F94A46A28BA9B8CF358CB0 Ref B: LON21EDGE1411 Ref C: 2020-08-19T07:59:04Z\r\nDate: Wed, 19 Aug 2020 07:59:03 GMT\r\n, ErrorMessage : {\"errors\":[{\"message\":\"'OwnerUserObjectId' must be a valid user object id\"}],\"operationId\":\"61a89e916cb8eb41a944101827872907\"}",
        "innerError": {
            "date": "2020-08-19T07:59:04",
            "request-id": "a8493bdd-8929-4199-9cf8-f3caa65fd514"
        }
    }
}

You have to use the beta API, if I recall correctly.
After more experimentation, I found that I could create classroom teams more reliably if I skipped creating an educationClass first, left out most of the initial parameters, used my desired mailNickname as the initial displayName, and then changed the displayName to something user-friendly afterwards. I send a POST to https://graph.microsoft.com/beta/teams to create the team:

{
  "displayName": "Teams_Classroom_12345_34FA8F",
  "[email protected]": "https://graph.microsoft.com/beta/teamsTemplates('educationClass')",
  "[email protected]": ["https://graph.microsoft.com/beta/users/<SERVICE_ACCOUNT_GUID>"]
}

(I set the initial owner to a service account, so the end user doesn't get confused by the initial display name)
The call returns a "location" header for the creation status, so I check that URL every 5-10 seconds until I get a "succeeded" response. Sometimes this can take a long time, so I stop trying after a minute or so and set up a process to check the URL once every hour. The "succeeded" response includes a targetResourceId GUID that points to the newly-created team, so I use that to send a PATCH request to https://graph.microsoft.com/beta/groups/<TARGET_RESOURCE_ID> to change the displayName:

{
    "displayName": "Ellie's test Team"
}

A POST to https://graph.microsoft.com/beta/groups/$teamId/owners/$ref to add the actual owner for the team:

{
    "@odata.id" => "https://graph.microsoft.com/beta/users/<OWNER_ACCOUNT_GUID>"
}

and then a DELETE to https://graph.microsoft.com/beta/groups/$teamId/owners/<SERVICE_ACCOUNT_GUID>/$ref to remove the service account.

Thank you for your quick answer, and then the group would be created correctly ?
My goal is to do like TEAMS classic process creation , to get the TEAM's calendar in outlook:

  1. Create the group
  2. Add a team to the group

To workaround a feature where we need to have the TEAM Calendar (group), showing in outlook : https://techcommunity.microsoft.com/t5/microsoft-teams-ama/why-the-teams-calendar-not-visible-in-outlook/td-p/300155
In this way I avoid using powershell to enable the calendar visibility in Outlook

Edit:
I got it working your way,

creating the educationClass, using /education/classes/{id}/group to retrieve the group object, then feeding the group object itself into the /teams POST request. For example, here's what I'm sending in that POST request: { "displayName": DISPLAYNAME, "[email protected]": "https://graph.microsoft.com/beta/teamsTemplates('TEMPLATE')", "[email protected]": ["https://graph.microsoft.com/beta/users/OWNER_ID"], "group": GROUP_OBJECT }

but setting the userID instead of Email
"[email protected]": ["https://graph.microsoft.com/beta/users/[email protected]"]

BUT, the teams calendar is not showing in outlook, as the group is created with those properties .. I still need to run a powershell to enable the group in Outlook... Why microsoft cant show calendar when we create a CLASS using Graph ?

"resourceBehaviorOptions": [
"SubscriptionDisabled",
"SharePointMemberReadonly",
"CalendarMemberReadOnly",
"WelcomeEmailDisabled",
"SubscribeNewGroupMembers",
"HideGroupInOutlook",
"ConnectorsDisabled",
"AllowOnlyMembersToPost"
],

Was this page helpful?
0 / 5 - 0 ratings