Lianja
Lianja
List Groups
See more Microsoft Group Examples
List 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.
Chilkat Lianja Downloads
llSuccess = .F.
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// Use your previously obtained access token as shown here:
// Get Microsoft Graph OAuth2 Access Token with Group.ReadWrite.All scope.
loJsonToken = createobject("CkJsonObject")
llSuccess = loJsonToken.LoadFile("qa_data/tokens/msGraphGroup.json")
if (llSuccess = .F.) then
? loJsonToken.LastErrorText
release loHttp
release loJsonToken
return
endif
loHttp.AuthToken = loJsonToken.StringOf("access_token")
// Send a GET request to https://graph.microsoft.com/v1.0/groups?$orderby=displayName
lcStrResponse = loHttp.QuickGetStr("https://graph.microsoft.com/v1.0/groups?$orderby=displayName")
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loJsonToken
return
endif
loJson = createobject("CkJsonObject")
loJson.Load(lcStrResponse)
loJson.EmitCompact = .F.
if (loHttp.LastStatus <> 200) then
? loJson.Emit()
? "Failed, response status code = " + str(loHttp.LastStatus)
release loHttp
release loJsonToken
release loJson
return
endif
? loJson.Emit()
// 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
lcOdataContext = loJson.StringOf('"@odata.context"')
i = 0
lnCount_i = loJson.SizeOfArray("value")
do while i < lnCount_i
loJson.I = i
lcId = loJson.StringOf("value[i].id")
lcDeletedDateTime = loJson.StringOf("value[i].deletedDateTime")
lcClassification = loJson.StringOf("value[i].classification")
lcCreatedDateTime = loJson.StringOf("value[i].createdDateTime")
lcDescription = loJson.StringOf("value[i].description")
lcDisplayName = loJson.StringOf("value[i].displayName")
lcMail = loJson.StringOf("value[i].mail")
llMailEnabled = loJson.BoolOf("value[i].mailEnabled")
lcMailNickname = loJson.StringOf("value[i].mailNickname")
lcOnPremisesLastSyncDateTime = loJson.StringOf("value[i].onPremisesLastSyncDateTime")
lcOnPremisesSecurityIdentifier = loJson.StringOf("value[i].onPremisesSecurityIdentifier")
lcOnPremisesSyncEnabled = loJson.StringOf("value[i].onPremisesSyncEnabled")
lcPreferredDataLocation = loJson.StringOf("value[i].preferredDataLocation")
lcRenewedDateTime = loJson.StringOf("value[i].renewedDateTime")
llSecurityEnabled = loJson.BoolOf("value[i].securityEnabled")
lcVisibility = loJson.StringOf("value[i].visibility")
j = 0
lnCount_j = loJson.SizeOfArray("value[i].creationOptions")
do while j < lnCount_j
loJson.J = j
// ...
j = j + 1
enddo
j = 0
lnCount_j = loJson.SizeOfArray("value[i].groupTypes")
do while j < lnCount_j
loJson.J = j
lcStrVal = loJson.StringOf("value[i].groupTypes[j]")
j = j + 1
enddo
j = 0
lnCount_j = loJson.SizeOfArray("value[i].proxyAddresses")
do while j < lnCount_j
loJson.J = j
lcStrVal = loJson.StringOf("value[i].proxyAddresses[j]")
j = j + 1
enddo
j = 0
lnCount_j = loJson.SizeOfArray("value[i].resourceBehaviorOptions")
do while j < lnCount_j
loJson.J = j
// ...
j = j + 1
enddo
j = 0
lnCount_j = loJson.SizeOfArray("value[i].resourceProvisioningOptions")
do while j < lnCount_j
loJson.J = j
// ...
j = j + 1
enddo
j = 0
lnCount_j = loJson.SizeOfArray("value[i].onPremisesProvisioningErrors")
do while j < lnCount_j
loJson.J = j
// ...
j = j + 1
enddo
i = i + 1
enddo
? "Success."
release loHttp
release loJsonToken
release loJson