Microsoft Teams : “Failed to create the plan” error while adding Planner to Teams which are created using Graph APIs

Hi All,
LIFE IS BEAUTIFUL 🙂 I hope we all are safe:) STAY SAFE, STAY HEALTHY 🙂 STAY HOME 🙂
Today new issue and solution 🙂
Background / Use Case : We were provisioning Teams using Microsoft Graph APIs. We have our custom Teams creations form where user can order the Team.
We have following code: This is simple code. There are other settings as well while creating Groups.
JObject group = new JObject();
JArray owners = new JArray();
owners.Add($"https://graph.microsoft.com/v1.0/users/{ownerId1}");
JArray groupTypes = new JArray();
groupTypes.Add("Unified");
group["description"] = "group description";
group["displayName"] = "group display name";
group["groupTypes"] = groupTypes;
group["mailNickname"] = "group mail nick name"
group["owners@odata.bind"] = owners;
var strcontent = group.ToString();
var content = new StringContent(strcontent, Encoding.UTF8, "application/json");
var result = await hc.PostAsync("https://graph.microsoft.com/v1.0/groups", content);
var resultStr = await result.Content.ReadAsStringAsync();
if (result.IsSuccessStatusCode){
//Group created successfully, provision the team
var teamSettings = new Team{
MemberSettings = new TeamMemberSettings
{
AllowCreateUpdateChannels = true
}
};
var team = await hc.PutAsJsonAsync($"https://graph.microsoft.com
/v1.0/groups/{groupId}/team", teamSettings);
}
With this code we are successfully able to create group and then Teams. Everything is working fine with Team either from Team desktop client or Team Web client.
But issue occurs when one of the owner of one team tried to add the Planner as

And then error occurs – “Failed to create the plan.” as

This error is in both in Teams desktop client and Team web client as well.
When we created the Teams from UI either through Teams desktop client or Teams web client, we are successfully able to add the Planner. So it seems this is the issue when we are creating Teams using Graph APIs.
After bit googling it found that this seems to be known issue and lots of colleagues has this issue. Following are few threads for such error for reference: https://delucagiuliano.com/microsoft-teams-failed-to-create-the-plan
https://github.com/microsoftgraph/microsoft-graph-docs/issues/7427
There is a user voice for the same as well – https://microsoftteams.uservoice.com/forums/908686-bug-reports/suggestions/39626701-planner-failed-to-create-plan
Solution: But then there is workaround as well 🙂 And workaround is “Adding Owner as a Member as well” . When I changed the code and added Owners as a Members as well it worked like a charm 🙂
Updated code: In above code added following line, added Owners as a Members as well –
group["members@odata.bind"] = owners;
After adding the above line, tested by creating new Teams and then owners could successfully add the Planner 🙂 But then this works for new Teams, for existing Teams we need to write a script – so the next article, shearing the script soon 🙂
Few more references – https://docs.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-1.0&tabs=csharp
Creating a Teams Programmatically
Create Plan Failed when creating Planner in Microsoft Teams
How to resolve ‘Failed to create Plan’ from Microsoft Teams
Thanks for reading 🙂 If its worth at least reading once, kindly please like and share. SHARING IS CARING 🙂
Enjoy the beautiful life 🙂 Have a FUN 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂
1 Response
[…] In my previous article related to Microsoft Teams we discussed the issue while adding Planner to Teams which are created using Graph APIs and workaround – Microsoft Teams : “Failed to create the plan” error while adding Planner to Teams which are crea… […]