Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Microsoft Teams - List Joined TeamsGet the teams in Microsoft Teams that the user is a direct member of. For more information, see https://docs.microsoft.com/en-us/graph/api/user-list-joinedteams?view=graph-rest-1.0&tabs=http
IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; 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. CkHttp::setCkAuthToken(http, "ACCESS_TOKEN") sbResponseBody.i = CkStringBuilder::ckCreate() If sbResponseBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkHttp::ckQuickGetSb(http,"https://graph.microsoft.com/v1.0/me/joinedTeams",sbResponseBody) If success = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbResponseBody) ProcedureReturn EndIf jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbResponseBody) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttp::ckLastStatus(http) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttp::ckLastHeader(http) Debug "Failed." CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn 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 id.s createdDateTime.s displayName.s description.s internalId.s classification.s specialization.s visibility.s webUrl.s isArchived.i isMembershipLimitedToOwners.s memberSettings.s guestSettings.s messagingSettings.s funSettings.s discoverySettings.s odata_context.s = CkJsonObject::ckStringOf(jResp,Chr(34) + "@odata.context" + Chr(34)) odata_count.i = CkJsonObject::ckIntOf(jResp,Chr(34) + "@odata.count" + Chr(34)) i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"value") While i < count_i CkJsonObject::setCkI(jResp, i) id = CkJsonObject::ckStringOf(jResp,"value[i].id") createdDateTime = CkJsonObject::ckStringOf(jResp,"value[i].createdDateTime") displayName = CkJsonObject::ckStringOf(jResp,"value[i].displayName") description = CkJsonObject::ckStringOf(jResp,"value[i].description") internalId = CkJsonObject::ckStringOf(jResp,"value[i].internalId") classification = CkJsonObject::ckStringOf(jResp,"value[i].classification") specialization = CkJsonObject::ckStringOf(jResp,"value[i].specialization") visibility = CkJsonObject::ckStringOf(jResp,"value[i].visibility") webUrl = CkJsonObject::ckStringOf(jResp,"value[i].webUrl") isArchived = CkJsonObject::ckBoolOf(jResp,"value[i].isArchived") isMembershipLimitedToOwners = CkJsonObject::ckStringOf(jResp,"value[i].isMembershipLimitedToOwners") memberSettings = CkJsonObject::ckStringOf(jResp,"value[i].memberSettings") guestSettings = CkJsonObject::ckStringOf(jResp,"value[i].guestSettings") messagingSettings = CkJsonObject::ckStringOf(jResp,"value[i].messagingSettings") funSettings = CkJsonObject::ckStringOf(jResp,"value[i].funSettings") discoverySettings = CkJsonObject::ckStringOf(jResp,"value[i].discoverySettings") i = i + 1 Wend CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.