Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    String sCreatedDateTime
    String sDisplayName
    String sDescription
    String sInternalId
    String sClassification
    String sSpecialization
    String sVisibility
    String sWebUrl
    Boolean iIsArchived
    String sIsMembershipLimitedToOwners
    String sMemberSettings
    String sGuestSettings
    String sMessagingSettings
    String sFunSettings
    String sDiscoverySettings
    String sOdata_context
    Integer iOdata_count
    Integer i
    Integer iCount_i
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // 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.
    Set ComAuthToken Of hoHttp To "ACCESS_TOKEN"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://graph.microsoft.com/v1.0/me/joinedTeams" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // 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

    Get ComStringOf Of hoJResp '"@odata.context"' To sOdata_context
    Get ComIntOf Of hoJResp '"@odata.count"' To iOdata_count
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "value" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "value[i].id" To sId
        Get ComStringOf Of hoJResp "value[i].createdDateTime" To sCreatedDateTime
        Get ComStringOf Of hoJResp "value[i].displayName" To sDisplayName
        Get ComStringOf Of hoJResp "value[i].description" To sDescription
        Get ComStringOf Of hoJResp "value[i].internalId" To sInternalId
        Get ComStringOf Of hoJResp "value[i].classification" To sClassification
        Get ComStringOf Of hoJResp "value[i].specialization" To sSpecialization
        Get ComStringOf Of hoJResp "value[i].visibility" To sVisibility
        Get ComStringOf Of hoJResp "value[i].webUrl" To sWebUrl
        Get ComBoolOf Of hoJResp "value[i].isArchived" To iIsArchived
        Get ComStringOf Of hoJResp "value[i].isMembershipLimitedToOwners" To sIsMembershipLimitedToOwners
        Get ComStringOf Of hoJResp "value[i].memberSettings" To sMemberSettings
        Get ComStringOf Of hoJResp "value[i].guestSettings" To sGuestSettings
        Get ComStringOf Of hoJResp "value[i].messagingSettings" To sMessagingSettings
        Get ComStringOf Of hoJResp "value[i].funSettings" To sFunSettings
        Get ComStringOf Of hoJResp "value[i].discoverySettings" To sDiscoverySettings
        Move (i + 1) To i
    Loop



End_Procedure