Can someone provide the procedure to add a MS Team tab containing a Planner plan?
This post is telling that the account that is creating the tab should be a member of the Team. Fine. I did add it and still, the plan tab creation isn't working.
You can find a snippet of my code bellow:
$graphAPIUrl = "https://graph.microsoft.com/v1.0"
$teamID = "TeamID-value"
$securedPassword = convertto-securestring -String $password -AsPlainText -Force
$creds = new-object -typename System.Management.Automation.PSCredential -argumentlist $login, $securedPassword
Connect-AzureAD -Credential $creds
Connect-PnPOnline -ClientId $GraphAppId -ClientSecret $GraphAppSecret -AADDomain $AADDomain
$token = Get-PnPGraphAccessToken
# Adding the plan into the team
$createPlanUri = "$($graphAPIUrl)/planner/plans"
$body = @{
"owner"= $teamID;
"title"= "Planner"
}
$headers = @{
"Authorization" = "Bearer $token"
}
$formatedBody = ConvertTo-Json -InputObject $body
$createPlanResponse = Invoke-RestMethod -Method Post -Uri $createPlanUri -Headers $headers -Body $formatedBody -ContentType "application/json"
Error message :
Invoke-RestMethod : {
"error": {
"code": "UnknownError",
"message": "\r\n\r\n\r\n\r\n401 - Unauthorized: Access is denied due to invalid credentials.\r\n\r\n\r\n\r\n\r\n\r\nServer Error\r\n\r\n \r\n 401 - Unauthorized: Access is denied due to invalid credentials.\r\n You do not have
permission to view this directory or page using the credentials that you supplied.\r\n \r\n\r\n\r\n\r\n",
"innerError": {
"date": "2020-09-16T13:29:50",
"request-id": "c2ccdd4f-9659-4c14-8575-6ea998a2392e",
"client-request-id": "c2ccdd4f-9659-4c14-8575-6ea998a2392e"
}
}
}
I dont need to specify that my credential are not wrong. I'm using them to do plenty of other thing as Team creation, OneNote nootebook creation and they are pefectly corrects.
What am I doing wrong ?