0

有人可以提供添加包含 Planner 计划的 MS Team 选项卡的过程吗?

这篇文章告诉创建选项卡的帐户应该是团队的成员。美好的。我确实添加了它,但仍然无法创建计划选项卡。

您可以在下面找到我的代码片段:

$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"

错误信息 :

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"
}
}
}

我不需要指定我的凭证没有错。我用它们来做很多其他的事情,比如团队创建、OneNote 笔记本创建,它们完全正确。

我究竟做错了什么 ?

4

0 回答 0