From 55af48d251ec7dcce463c050ca58b93a6de352d8 Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Sat, 1 Jun 2024 20:11:06 +0200 Subject: [PATCH] Fix New-PnPTeamsTeam sometimes "Conflict (409): Team already exists" Handle "Conflict (409): Team already exists" error as a case of "a previous teamify call succeeded". Fix #3964 --- src/Commands/Utilities/TeamsUtility.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Commands/Utilities/TeamsUtility.cs b/src/Commands/Utilities/TeamsUtility.cs index a5cd0d376..2085f758f 100644 --- a/src/Commands/Utilities/TeamsUtility.cs +++ b/src/Commands/Utilities/TeamsUtility.cs @@ -209,7 +209,12 @@ public static async Task NewTeamAsync(string accessToken, PnPConnection co } retry = false; } - + catch (GraphException ge) when (ge.HttpResponse.StatusCode == System.Net.HttpStatusCode.Conflict) + { + // Handle conflict exceptions as if it succeeded, as it means a previous request succeeded enabling teams + returnTeam = await GetTeamAsync(accessToken, connection, group.Id); + retry = false; + } catch (Exception) { await Task.Delay(5000);