cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork
Super User
Super User

Creating a private channel in HTTP request does not generate sharepoint site

Hi

 

Im having some issue here, i know the creating of private channel using microsoft graph is in beta.

So i create a team and then i create a private channel in this team using a HTTP request posting to microsoft graph, everything works as it should and the private channel is created.

 

But the SharePoint site for the private channel is not generated until you actually open the Teams app and go to the private channel and click on the files tab. Then it generates the SharePoint site.

 

I know this was an issue before when creating a Team using the same method.

Please if anyone know how i can trigger a interaction or something so the SharePoint site starts to generate on the private channel in Teams?

10 REPLIES 10
v-alzhan-msft
Community Support
Community Support

Hi @JimmyWork ,

 

Could you please share a screenshot of the configuration of your flow?

 

Best regards,
Alice       
 
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@v-alzhan-msft Here comes my flow, i have made it as small as possible for test.

The issue is that the private channel site is never generated until i manually opens teams and visit the channel. So i cant get any data from the private channel except channel id, but not siteID or drive id and so on because they are not generated until you open the channel in Teams for the first time.

 

I can add that if i post everything in graph explorer it works but creating it using a HTTP in flow to graph will not give the same result.

 

2020-02-05 14_17_53-.png

 

If you try to use get list or anything on the private channel it will fail because it's not created. And there is no provisioning time for it it's just created when you open the channel, thats the only trigger i found.

 

Get list to private channel webURL

"message": "We didn't find a site with this address. Make sure you are entering the exact address of the site.\r\nclientRequestId:

@v-alzhan-msft 

The issue is like this: https://powerusers.microsoft.com/t5/Building-Flows/Teams-Channel-creation-using-flow-does-not-create...

 

Except for private channel the SharePoint site is not generated until you visit the files tab in the private channel. This really creates issues because i can never create folders or anything in that private channel in flow as it will fail because the SharePoint site have not been generated even if the channel is created.

No one?

Rodriguez
Regular Visitor

No one?

BM-HV
Frequent Visitor

Is there a solution for this? We're facing the same issue: we can't migrate to private channels which we've created via the Graph API in application context as the SharePoint site isn't created.

There is a solution to this as we have implemented something like this in one of our solutions, I believe it is using PowerShell. I can check this in Monday and update this post.

JimmyWork
Super User
Super User

Currently we have a delay set for 30sec after creating the private channel.
You can also call Documents folder using Microsoft Graph, this would trigger provisioning of the SPO site.

I believe using Get-filesFolder calling the documents folder of the private channel would trigger the provisioning.
https://docs.microsoft.com/en-us/graph/api/channel-get-filesfolder?view=graph-rest-1.0&tabs=http

 

https://github.com/microsoftgraph/microsoft-graph-docs/issues/10206

I have more than 1,500 private channels, each one in an own Teams. I'm calling "/filesfolder" via a PowerShell script against an AAD app registry with application permissions (Group Read/Write All):

Invoke-RestMethod -Headers @{Authorization = "Bearer $accessToken" } -Uri "https://graph.microsoft.com/v1.0/teams/$($team.ObjectId)/channels/$($primaryChannel.id)/filesFolder"

Result: time-out and no SharePoint site provisioned.

 

This is the whole script, even though it doesn't help because it seems like calling "/filesfolder" is not triggering SPO site creation.

$maxRetryCount = 100

#Get the stored credentials from the Windows Credential Store
$credential = Get-PnPStoredCredential -Name 'MyAADApp'
 
#Connect to SharePoint Online using clientApp and certificate credentials
Connect-PnPOnline -Url "https://tenant-admin.sharepoint.com" -ClientId $credential.UserName -Thumbprint $credential.GetNetworkCredential().Password -Tenant "tenant.onmicrosoft.com" -ReturnConnection
 
#Request graph access toeken
$accessToken = Get-PnPGraphAccessToken

#Get teams from projects list
Connect-AzureAD
$teams = Get-AzureADGroup -All:$true | Where-Object {$_.MailNickname.StartsWith('MyProjectTeams-')}
 
#Loop through each team
foreach ($team in $teams) {
    Write-Host $team.DisplayName -ForegroundColor White -BackgroundColor Green
 
    #Capture critical errors on rowlevel
    try {
 
        #Get the primary channel
        $primaryChannel = Invoke-RestMethod -Headers @{Authorization = "Bearer $accessToken" } -Uri "https://graph.microsoft.com/v1.0/teams/$($team.ObjectId)/primaryChannel" -Method 'GET' -ContentType 'application/json' | Select-Object 'displayName', 'id'
        $privateChannels = (Invoke-RestMethod -Headers @{Authorization = "Bearer $accessToken" } -Uri "https://graph.microsoft.com/v1.0/teams/$($team.ObjectId)/channels?`$filter=membershipType eq `'private`'" -Method 'GET' -ContentType 'application/json').value | Select-Object 'displayName', 'id'
 
        #Trigger private channel SharePoint Onlinesite creation
        Invoke-RestMethod -Headers @{Authorization = "Bearer $accessToken" } -Uri "https://graph.microsoft.com/v1.0/teams/$($team.ObjectId)/channels/$($primaryChannel.id)/filesFolder" | Out-Null
        
        Write-Host $privateChannels
        if($privateChannels -ne $null){
            foreach ($privateChannel in $privateChannels) {
 
                #Attempt private channel check
                $stopLoop = $false
                [int]$retryCount = '0'
 
                do {
                    try {
                        Invoke-RestMethod -Headers @{Authorization = "Bearer $accessToken" } -Uri "https://graph.microsoft.com/v1.0/teams/$($team.ObjectId)/channels/$($privateChannel.id)/filesFolder"
                        $stopLoop = $true
                    }
                    catch {
                        if ($retryCount -gt $maxRetryCount) {
                            $stoploop = $true
                        }
                        else {
 
                            Start-Sleep -Seconds 5
                            $retryCount = $retryCount + 1
                        }
                    }
                }
                While ($stopLoop -eq $false)
 
            }
        }else{
            Write-Host "No private channel. Create the private channel."
        }
    }
    catch {
 
        Write-Host $_
 
    }
 
}

 

I will check if I can get our code. And post it

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,578)