0
votes

I try to archive a Microsoft team

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

I become 403 error.

{ "error": { "code": "AccessDenied", "message": "Unable to fetch team thread: Failed to execute Skype backend request GetThreadRequest.", "innerError": { "request-id": "99b1dd19-7f58-4237-bb80-d04345d67ae5", "date": "2019-03-03T23:18:55" } } }

What I do wrong?

Delete the team will work

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

The same result came with the Microsoft graph explorer (here I give me all possible permissions)

1

1 Answers

0
votes

I don't see anything wrong with your approach -- I've included the Python code I use to archive Teams below, and the same process appears to be used in your code. This could be a transient error. I got the same message a few days ago when some change precluded new channels from being created (even in the 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))