使用Microsoft graph归档Microsoft团队

时间:2019-03-04 00:12:06

标签: python microsoft-graph

我尝试归档Microsoft团队

$scopes = 'Group.ReadWrite.All'

$appid = ‘’
$appsecret = ''
$appaaddomain = ''


$url = "https://graph.microsoft.com/v1.0/teams/{team-id}/archive" 

…

Invoke-RestMethod -Method "Post" -Uri $url -Headers @{Authorization = "Bearer $token"

我变成403错误。

  

{       “错误”:{           “ code”:“ AccessDenied”,           “ message”:“无法获取团队线程:无法执行Skype后端请求GetThreadRequest。”,           “ innerError”:{               “ request-id”:“ 99b1dd19-7f58-4237-bb80-d04345d67ae5”,               “ date”:“ 2019-03-03T23:18:55”           }       }

我做错了什么?

删除团队将工作的人

$scopes = 'Group.ReadWrite.All'

$appid = ‘’
$appsecret = ''
$appaaddomain = ''


$url = "https://graph.microsoft.com/v1.0/groups/{team-id}"  

…


Invoke-RestMethod -Method "Delete" -Uri $url -Headers @{Authorization = "Bearer $token"

Microsoft graph Explorer产生了相同的结果(在这里我给了我所有可能的权限)

1 个答案:

答案 0 :(得分:0)

我认为您的方法没有任何问题-我在下面包含了用于存档团队的Python代码,并且您的代码中似乎使用了相同的过程。 可能是暂时性错误。几天前,当某些更改导致无法创建新通道时(即使在GUI中),我也收到了相同的消息。

import requests
import json
# config file with site-specific values
from config import strClientID, strClientSecret, strGraphAuthURL, strTenantID

postData = {"grant_type": "client_credentials","client_id" : strClientID,"client_secret": strClientSecret,"scope": "https://graph.microsoft.com/.default"}

r = requests.post(strGraphAuthURL, data=postData)

strJSONResponse = r.text
if len(strJSONResponse) > 5:
    jsonResponse = json.loads(strJSONResponse)
    strAccessToken = jsonResponse['access_token']

    getHeader = {"Authorization": "Bearer " + strAccessToken }

    postRecord = requests.post("https://graph.microsoft.com/beta/teams/{teamID}/archive",headers={"Authorization": "Bearer " + strAccessToken})
    print("HTTP Status Code:\t%s\nResult code content:\t%s" % (postRecord.status_code, postRecord.content))