private async Task CreateUserRoleAssignmentsAsync(HttpClient httpClient, IList <string> users, Guid spaceId, UserAadObjectIdsDescription userAadObjectIds) { if (spaceId == Guid.Empty) { throw new ArgumentException($"User Role Assignment must have a {nameof( spaceId )}"); } foreach (string user in users) { if (userAadObjectIds.TryGetValue(user, out string oid)) { string spacePath = await SpaceHelpers.GetSpaceFullPathAsync(httpClient, spaceId); if (string.IsNullOrWhiteSpace(spacePath)) { Console.WriteLine($"Unable to get the full path for the current space. Cannot create a role assignment. (Space Id: {spaceId})"); continue; } var roleAssignment = new RoleAssignment { RoleId = RoleAssignment.RoleIds.User, ObjectId = oid, ObjectIdType = RoleAssignment.ObjectIdTypes.UserId, TenantId = Tenant, Path = spacePath }; var existingRoleAssignment = await roleAssignment.GetUniqueRoleAssignmentAsync(httpClient); if (existingRoleAssignment == null) { await roleAssignment.CreateRoleAssignmentAsync(httpClient, JsonSerializerSettings); } else { Console.WriteLine($"{nameof( RoleAssignment )} already exists, so skipping creation."); } } } }