AutoIt
AutoIt
Microsoft Teams - List Team Members
See more Microsoft Teams Examples
Get the members of a team.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; Implements the following CURL command:
; curl -X GET https://graph.microsoft.com/v1.0/teams/{teamsId}/members \
; -H 'authorization: Bearer ACCESS_TOKEN'
; Use the following online tool to generate HTTP code from a CURL command
; Convert a cURL Command to HTTP Source Code
; Adds the "Authorization: Bearer ACCESS_TOKEN" header.
$oHttp.AuthToken = "ACCESS_TOKEN"
$oHttp.SetUrlVar("teamsId","285c8d65-d8b5-447a-91c7-85593d50c826")
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://graph.microsoft.com/v1.0/teams/{$teamsId}/members",$oSbResponseBody)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oHttp.LastHeader & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('285c8d65-d8b5-447a-91c7-85593d50c826')/members",
; "@odata.count": 1,
; "value": [
; {
; "@odata.type": "#microsoft.graph.aadUserConversationMember",
; "id": "Mjg1YzhkNjUtZDhiNS00NDdhLTkxYzctODU1OTNkNTBjODI2IyM0ZWU3MzJjMz0zMjJlLTRhNmItYjcyOS0yZmQxZWI1YzYwMDQ=",
; "roles": [
; "owner"
; ],
; "displayName": "Joe Smith",
; "userId": "4ee732c3-322e-4a6b-b729-2fd1eb5c6004",
; "email": "admin@chilkat365.com"
; }
; ]
; }
; Sample code for parsing the JSON response...
; Use the following online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON
Local $sOdata_type
Local $sId
Local $sDisplayName
Local $sUserId
Local $sEmail
Local $iJ
Local $iCount_j
Local $strVal
Local $sOdata_context = $oJResp.StringOf("""@odata.context""")
Local $iOdata_count = $oJResp.IntOf("""@odata.count""")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("value")
While $i < $iCount_i
$oJResp.I = $i
$sOdata_type = $oJResp.StringOf("value[i].""@odata.type""")
$sId = $oJResp.StringOf("value[i].id")
$sDisplayName = $oJResp.StringOf("value[i].displayName")
$sUserId = $oJResp.StringOf("value[i].userId")
$sEmail = $oJResp.StringOf("value[i].email")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("value[i].roles")
While $iJ < $iCount_j
$oJResp.J = $iJ
$strVal = $oJResp.StringOf("value[i].roles[j]")
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend