Skip to content

Commit 14bfc3a

Browse files
Fix New-PnPTeamsTeam sometimes "Conflict (409): Team already exists" (pnp#3992)
Handle "Conflict (409): Team already exists" error as a case of "a previous teamify call succeeded". Fix pnp#3964 Co-authored-by: Gautam Sheth <gautamdsheth@outlook.com>
1 parent edee0ba commit 14bfc3a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Commands/Utilities/TeamsUtility.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ public static async Task<Team> NewTeamAsync(string accessToken, PnPConnection co
209209
}
210210
retry = false;
211211
}
212-
212+
catch (GraphException ge) when (ge.HttpResponse.StatusCode == System.Net.HttpStatusCode.Conflict)
213+
{
214+
// Handle conflict exceptions as if it succeeded, as it means a previous request succeeded enabling teams
215+
returnTeam = await GetTeamAsync(accessToken, connection, group.Id);
216+
retry = false;
217+
}
213218
catch (Exception)
214219
{
215220
await Task.Delay(5000);

0 commit comments

Comments
 (0)