public async Task <string> CreateTeamUsingClone(Flight flight)
        {
            var response = await HttpPostWithHeaders($"/teams/{flight.prototypeTeamId}/clone",
                                                     new TeamCloneRequestBody()
            {
                DisplayName  = "Flight 4" + flight.number,
                MailNickname = "flight" + GetTimestamp(),
                Description  = "Everything about flight " + flight.number,
                Visibility   = TeamVisibilityType.Private,
                PartsToClone = ClonableTeamParts.Apps | ClonableTeamParts.Settings | ClonableTeamParts.Channels,
            });

            string operationUrl = response.Headers.Location.ToString();

            string teamId = null;

            for (; ;)
            {
                TeamsAsyncOperation operation = await HttpGet <TeamsAsyncOperation>(operationUrl);

                if (operation.Status == TeamsAsyncOperationStatus.Failed)
                {
                    throw new Exception();
                }

                if (operation.Status == TeamsAsyncOperationStatus.Succeeded)
                {
                    teamId = operation.TargetResourceId;
                    break;
                }

                Thread.Sleep(10000); // wait 10 seconds between polls
            }

            var graph = GetAuthenticatedClient();

            // Add the crew to the team
            foreach (string upn in flight.crew)
            {
                var user = await GetUserFromUpn(upn);

                await graph.Groups[teamId].Members.References.Request().AddAsync(
                    user);

                if (upn == flight.captain)
                {
                    await graph.Groups[teamId].Owners.References.Request().AddAsync(
                        user);
                }
            }

            // get the webUrl
            Team   team = await graph.Teams[teamId].Request().GetAsync();
            string link = team.WebUrl;

            return(link);
        }
        public async Task <string> CreateTeamUsingClone(Flight flight)
        {
            var response = await HttpPostWithHeaders($"/teams/{flight.prototypeTeamId}/clone",
                                                     new Clone()
            {
                displayName        = "Flight 4" + flight.number,
                mailNickName       = "flight" + GetTimestamp(),
                description        = "Everything about flight " + flight.number,
                teamVisibilityType = "Private",
                partsToClone       = "apps,settings,channels"
            });

            string operationUrl = response.Headers.Location.ToString();

            string teamId = null;

            for (; ;)
            {
                TeamsAsyncOperation operation = await HttpGet <TeamsAsyncOperation>(operationUrl);

                if (operation.Status == AsyncOperationStatus.Failed)
                {
                    throw new Exception();
                }

                if (operation.Status == AsyncOperationStatus.Succeeded)
                {
                    teamId = operation.targetResourceId;
                    break;
                }

                Thread.Sleep(10000); // wait 10 seconds between polls
            }

            // Add the crew to the team
            foreach (string upn in flight.crew)
            {
                string payload = $"{{ '@odata.id': '{graphV1Endpoint}/users/{upn}' }}";
                await HttpPost($"/groups/{teamId}/members/$ref", payload);

                if (upn == flight.captain)
                {
                    await HttpPost($"/groups/{teamId}/owners/$ref", payload);
                }
            }

            // get the webUrl
            Team team = await HttpGet <Team>($"/teams/{teamId}");

            string link = team.WebUrl;

            return(link);
        }