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) List GroupsList all the groups available in an organization, including but not limited to Office 365 Groups. See https://docs.microsoft.com/en-us/graph/api/group-list?view=graph-rest-1.0 for more information.
IncludeFile "CkJsonObject.pb" IncludeFile "CkHttp.pb" Procedure ChilkatExample() ; This example requires 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 ; Use your previously obtained access token as shown here: ; Get Microsoft Graph OAuth2 Access Token with Group.ReadWrite.All scope. jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/msGraphGroup.json") If success = 0 Debug CkJsonObject::ckLastErrorText(jsonToken) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf CkHttp::setCkAuthToken(http, CkJsonObject::ckStringOf(jsonToken,"access_token")) ; Send a GET request to https://graph.microsoft.com/v1.0/groups?$orderby=displayName strResponse.s = CkHttp::ckQuickGetStr(http,"https://graph.microsoft.com/v1.0/groups?$orderby=displayName") If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,strResponse) CkJsonObject::setCkEmitCompact(json, 0) If CkHttp::ckLastStatus(http) <> 200 Debug CkJsonObject::ckEmit(json) Debug "Failed, response status code = " + Str(CkHttp::ckLastStatus(http)) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkJsonObject::ckDispose(json) ProcedureReturn EndIf Debug CkJsonObject::ckEmit(json) ; Sample output: ; (See parsing code below..) ; { ; "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups", ; "value": [ ; { ; "id": "45b7d2e7-b882-4a80-ba97-10b7a63b8fa4", ; "deletedDateTime": null, ; "classification": null, ; "createdDateTime": "2018-12-22T02:21:05Z", ; "creationOptions": [], ; "description": "Self help community for golf", ; "displayName": "Golf Assist", ; "groupTypes": [ ; "Unified" ; ], ; "mail": "golfassist@contoso.com", ; "mailEnabled": true, ; "mailNickname": "golfassist", ; "onPremisesLastSyncDateTime": null, ; "onPremisesSecurityIdentifier": null, ; "onPremisesSyncEnabled": null, ; "preferredDataLocation": "CAN", ; "proxyAddresses": [ ; "smtp:golfassist@contoso.onmicrosoft.com", ; "SMTP:golfassist@contoso.com" ; ], ; "renewedDateTime": "2018-12-22T02:21:05Z", ; "resourceBehaviorOptions": [], ; "resourceProvisioningOptions": [], ; "securityEnabled": false, ; "visibility": "Public", ; "onPremisesProvisioningErrors": [] ; }, ; { ; "id": "d7797254-3084-44d0-99c9-a3b5ab149538", ; "deletedDateTime": null, ; "classification": null, ; "createdDateTime": "2018-11-19T20:29:40Z", ; "creationOptions": [], ; "description": "Talk about golf", ; "displayName": "Golf Discussion", ; "groupTypes": [], ; "mail": "golftalk@contoso.com", ; "mailEnabled": true, ; "mailNickname": "golftalk", ; "onPremisesLastSyncDateTime": null, ; "onPremisesSecurityIdentifier": null, ; "onPremisesSyncEnabled": null, ; "preferredDataLocation": "CAN", ; "proxyAddresses": [ ; "smtp:golftalk@contoso.onmicrosoft.com", ; "SMTP:golftalk@contoso.com" ; ], ; "renewedDateTime": "2018-11-19T20:29:40Z", ; "resourceBehaviorOptions": [], ; "resourceProvisioningOptions": [], ; "securityEnabled": false, ; "visibility": null, ; "onPremisesProvisioningErrors": [] ; } ; ] ; } ; ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON odataContext.s i.i count_i.i id.s deletedDateTime.s classification.s createdDateTime.s description.s displayName.s mail.s mailEnabled.i mailNickname.s onPremisesLastSyncDateTime.s onPremisesSecurityIdentifier.s onPremisesSyncEnabled.s preferredDataLocation.s renewedDateTime.s securityEnabled.i visibility.s j.i count_j.i strVal.s odataContext = CkJsonObject::ckStringOf(json,Chr(34) + "@odata.context" + Chr(34)) i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"value") While i < count_i CkJsonObject::setCkI(json, i) id = CkJsonObject::ckStringOf(json,"value[i].id") deletedDateTime = CkJsonObject::ckStringOf(json,"value[i].deletedDateTime") classification = CkJsonObject::ckStringOf(json,"value[i].classification") createdDateTime = CkJsonObject::ckStringOf(json,"value[i].createdDateTime") description = CkJsonObject::ckStringOf(json,"value[i].description") displayName = CkJsonObject::ckStringOf(json,"value[i].displayName") mail = CkJsonObject::ckStringOf(json,"value[i].mail") mailEnabled = CkJsonObject::ckBoolOf(json,"value[i].mailEnabled") mailNickname = CkJsonObject::ckStringOf(json,"value[i].mailNickname") onPremisesLastSyncDateTime = CkJsonObject::ckStringOf(json,"value[i].onPremisesLastSyncDateTime") onPremisesSecurityIdentifier = CkJsonObject::ckStringOf(json,"value[i].onPremisesSecurityIdentifier") onPremisesSyncEnabled = CkJsonObject::ckStringOf(json,"value[i].onPremisesSyncEnabled") preferredDataLocation = CkJsonObject::ckStringOf(json,"value[i].preferredDataLocation") renewedDateTime = CkJsonObject::ckStringOf(json,"value[i].renewedDateTime") securityEnabled = CkJsonObject::ckBoolOf(json,"value[i].securityEnabled") visibility = CkJsonObject::ckStringOf(json,"value[i].visibility") j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].creationOptions") While j < count_j CkJsonObject::setCkJ(json, j) ; ... j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].groupTypes") While j < count_j CkJsonObject::setCkJ(json, j) strVal = CkJsonObject::ckStringOf(json,"value[i].groupTypes[j]") j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].proxyAddresses") While j < count_j CkJsonObject::setCkJ(json, j) strVal = CkJsonObject::ckStringOf(json,"value[i].proxyAddresses[j]") j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].resourceBehaviorOptions") While j < count_j CkJsonObject::setCkJ(json, j) ; ... j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].resourceProvisioningOptions") While j < count_j CkJsonObject::setCkJ(json, j) ; ... j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].onPremisesProvisioningErrors") While j < count_j CkJsonObject::setCkJ(json, j) ; ... j = j + 1 Wend i = i + 1 Wend Debug "Success." CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.