Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cId
LOCAL cCreatedDateTime
LOCAL cDisplayName
LOCAL cDescription
LOCAL cInternalId
LOCAL cClassification
LOCAL cSpecialization
LOCAL cVisibility
LOCAL cWebUrl
LOCAL nIsArchived
LOCAL cIsMembershipLimitedToOwners
LOCAL cMemberSettings
LOCAL cGuestSettings
LOCAL cMessagingSettings
LOCAL cFunSettings
LOCAL cDiscoverySettings
LOCAL cOdata_context
LOCAL nOdata_count
LOCAL i
LOCAL nCount_i

nSuccess := 0

//  This example assumes the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oHttp := CreateObject("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 := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://graph.microsoft.com/v1.0/me/joinedTeams", oSbResponseBody)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oSbResponseBody:destroy()
    RETURN
ENDIF

oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0

? "Response Body:"
? oJResp:Emit()

nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
    ? "Response Header:"
    ? oHttp:LastHeader
    ? "Failed."
    oHttp:destroy()
    oSbResponseBody:destroy()
    oJResp:destroy()
    RETURN
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

cOdata_context := oJResp:StringOf('"@odata.context"')
nOdata_count := oJResp:IntOf('"@odata.count"')
i := 0
nCount_i := oJResp:SizeOfArray("value")
DO WHILE i < nCount_i
    oJResp:I := i
    cId := oJResp:StringOf("value[i].id")
    cCreatedDateTime := oJResp:StringOf("value[i].createdDateTime")
    cDisplayName := oJResp:StringOf("value[i].displayName")
    cDescription := oJResp:StringOf("value[i].description")
    cInternalId := oJResp:StringOf("value[i].internalId")
    cClassification := oJResp:StringOf("value[i].classification")
    cSpecialization := oJResp:StringOf("value[i].specialization")
    cVisibility := oJResp:StringOf("value[i].visibility")
    cWebUrl := oJResp:StringOf("value[i].webUrl")
    nIsArchived := oJResp:BoolOf("value[i].isArchived")
    cIsMembershipLimitedToOwners := oJResp:StringOf("value[i].isMembershipLimitedToOwners")
    cMemberSettings := oJResp:StringOf("value[i].memberSettings")
    cGuestSettings := oJResp:StringOf("value[i].guestSettings")
    cMessagingSettings := oJResp:StringOf("value[i].messagingSettings")
    cFunSettings := oJResp:StringOf("value[i].funSettings")
    cDiscoverySettings := oJResp:StringOf("value[i].discoverySettings")
    i := i + 1
ENDDO

oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()