Sample code for 30+ languages & platforms
AutoIt

Microsoft Teams - List Joined Teams

See more Microsoft Teams Examples

Get the teams in Microsoft Teams that the user is a direct member of.

Chilkat AutoIt Downloads

AutoIt
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/me/joinedTeams \
;   -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"

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://graph.microsoft.com/v1.0/me/joinedTeams",$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",
;   "@odata.count": 3,
;   "value": [
;     {
;       "id": "285c8d65-d8b5-447a-91c7-85593d50c826",
;       "createdDateTime": null,
;       "displayName": "Chilkat Software, Inc.",
;       "description": null,
;       "internalId": null,
;       "classification": null,
;       "specialization": null,
;       "visibility": null,
;       "webUrl": null,
;       "isArchived": false,
;       "isMembershipLimitedToOwners": null,
;       "memberSettings": null,
;       "guestSettings": null,
;       "messagingSettings": null,
;       "funSettings": null,
;       "discoverySettings": null
;     },
;     {
;       "id": "e527a8b1-5620-4dcf-9b29-a4713e9afa72",
;       "createdDateTime": null,
;       "displayName": "My Sample Team",
;       "description": "My Sample Team\u2019s Description",
;       "internalId": null,
;       "classification": null,
;       "specialization": null,
;       "visibility": null,
;       "webUrl": null,
;       "isArchived": false,
;       "isMembershipLimitedToOwners": null,
;       "memberSettings": null,
;       "guestSettings": null,
;       "messagingSettings": null,
;       "funSettings": null,
;       "discoverySettings": null
;     },
;     {
;       "id": "bc6ef2f4-d51e-4362-9a17-11ad3382b8ad",
;       "createdDateTime": null,
;       "displayName": "Sample Engineering Team",
;       "description": "This is a sample engineering team, used to showcase the range of properties supported by this API",
;       "internalId": null,
;       "classification": null,
;       "specialization": null,
;       "visibility": null,
;       "webUrl": null,
;       "isArchived": false,
;       "isMembershipLimitedToOwners": null,
;       "memberSettings": null,
;       "guestSettings": null,
;       "messagingSettings": null,
;       "funSettings": null,
;       "discoverySettings": null
;     }
;   ]
; }

; 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 $sId
Local $sCreatedDateTime
Local $sDisplayName
Local $sDescription
Local $sInternalId
Local $sClassification
Local $specialization
Local $sVisibility
Local $sWebUrl
Local $bIsArchived
Local $sIsMembershipLimitedToOwners
Local $sMemberSettings
Local $sGuestSettings
Local $sMessagingSettings
Local $sFunSettings
Local $sDiscoverySettings

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
    $sId = $oJResp.StringOf("value[i].id")
    $sCreatedDateTime = $oJResp.StringOf("value[i].createdDateTime")
    $sDisplayName = $oJResp.StringOf("value[i].displayName")
    $sDescription = $oJResp.StringOf("value[i].description")
    $sInternalId = $oJResp.StringOf("value[i].internalId")
    $sClassification = $oJResp.StringOf("value[i].classification")
    $specialization = $oJResp.StringOf("value[i].specialization")
    $sVisibility = $oJResp.StringOf("value[i].visibility")
    $sWebUrl = $oJResp.StringOf("value[i].webUrl")
    $bIsArchived = $oJResp.BoolOf("value[i].isArchived")
    $sIsMembershipLimitedToOwners = $oJResp.StringOf("value[i].isMembershipLimitedToOwners")
    $sMemberSettings = $oJResp.StringOf("value[i].memberSettings")
    $sGuestSettings = $oJResp.StringOf("value[i].guestSettings")
    $sMessagingSettings = $oJResp.StringOf("value[i].messagingSettings")
    $sFunSettings = $oJResp.StringOf("value[i].funSettings")
    $sDiscoverySettings = $oJResp.StringOf("value[i].discoverySettings")
    $i = $i + 1
Wend