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
(AutoIt) Create GroupCreate a new group as specified in the request body. You can create one of three types of groups:
This operation returns by default only a subset of the properties for each group. These default properties are noted in the Properties section. See https://docs.microsoft.com/en-us/graph/api/group-post-groups?view=graph-rest-1.0 for more information.
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") ; Use your previously obtained access token as shown here: ; Get Microsoft Graph OAuth2 Access Token with Group.ReadWrite.All scope. $oJsonToken = ObjCreate("Chilkat.JsonObject") Local $bSuccess = $oJsonToken.LoadFile("qa_data/tokens/msGraphGroup.json") If ($bSuccess = False) Then ConsoleWrite($oJsonToken.LastErrorText & @CRLF) Exit EndIf $oHttp.AuthToken = $oJsonToken.StringOf("access_token") ; Create a JSON body for the HTTP POST ; Use this online tool to generate the code from sample JSON: ; Generate Code to Create JSON ; { ; "description": "Self help community for library", ; "displayName": "Library Assist", ; "groupTypes": [ ; "Unified" ; ], ; "mailEnabled": true, ; "mailNickname": "library", ; "securityEnabled": false ; } $oJson = ObjCreate("Chilkat.JsonObject") $oJson.UpdateString("description","Self help community for library") $oJson.UpdateString("displayName","Library Assist") $oJson.UpdateString("groupTypes[0]","Unified") $oJson.UpdateBool("mailEnabled",True) $oJson.UpdateString("mailNickname","library") $oJson.UpdateBool("securityEnabled",False) ; POST the JSON to https://graph.microsoft.com/v1.0/groups Local $oResp = $oHttp.PostJson3("https://graph.microsoft.com/v1.0/groups","application/json",$oJson) If ($oHttp.LastMethodSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oJson.Load($oResp.BodyStr) $oJson.EmitCompact = False If ($oResp.StatusCode <> 201) Then ConsoleWrite($oJson.Emit() & @CRLF) ConsoleWrite("Failed, response status code = " & $oResp.StatusCode & @CRLF) Exit EndIf ConsoleWrite($oJson.Emit() & @CRLF) ; A sample response: ; (See code for parsing this response below..) ; { ; "id": "b320ee12-b1cd-4cca-b648-a437be61c5cd", ; "deletedDateTime": null, ; "classification": null, ; "createdDateTime": "2018-12-22T00:51:37Z", ; "creationOptions": [], ; "description": "Self help community for library", ; "displayName": "Library Assist", ; "groupTypes": [ ; "Unified" ; ], ; "mail": "library7423@contoso.com", ; "mailEnabled": true, ; "mailNickname": "library", ; "onPremisesLastSyncDateTime": null, ; "onPremisesSecurityIdentifier": null, ; "onPremisesSyncEnabled": null, ; "preferredDataLocation": "CAN", ; "proxyAddresses": [ ; "SMTP:library7423@contoso.com" ; ], ; "renewedDateTime": "2018-12-22T00:51:37Z", ; "resourceBehaviorOptions": [], ; "resourceProvisioningOptions": [], ; "securityEnabled": false, ; "visibility": "Public", ; "onPremisesProvisioningErrors": [] ; } ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON Local $sId Local $sDeletedDateTime Local $sClassification Local $sCreatedDateTime Local $sDescription Local $sDisplayName Local $sMail Local $bMailEnabled Local $sMailNickname Local $sOnPremisesLastSyncDateTime Local $sOnPremisesSecurityIdentifier Local $sOnPremisesSyncEnabled Local $sPreferredDataLocation Local $sRenewedDateTime Local $bSecurityEnabled Local $sVisibility Local $i Local $iCount_i Local $strVal $sId = $oJson.StringOf("id") $sDeletedDateTime = $oJson.StringOf("deletedDateTime") $sClassification = $oJson.StringOf("classification") $sCreatedDateTime = $oJson.StringOf("createdDateTime") $sDescription = $oJson.StringOf("description") $sDisplayName = $oJson.StringOf("displayName") $sMail = $oJson.StringOf("mail") $bMailEnabled = $oJson.BoolOf("mailEnabled") $sMailNickname = $oJson.StringOf("mailNickname") $sOnPremisesLastSyncDateTime = $oJson.StringOf("onPremisesLastSyncDateTime") $sOnPremisesSecurityIdentifier = $oJson.StringOf("onPremisesSecurityIdentifier") $sOnPremisesSyncEnabled = $oJson.StringOf("onPremisesSyncEnabled") $sPreferredDataLocation = $oJson.StringOf("preferredDataLocation") $sRenewedDateTime = $oJson.StringOf("renewedDateTime") $bSecurityEnabled = $oJson.BoolOf("securityEnabled") $sVisibility = $oJson.StringOf("visibility") $i = 0 $iCount_i = $oJson.SizeOfArray("creationOptions") While $i < $iCount_i $oJson.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJson.SizeOfArray("groupTypes") While $i < $iCount_i $oJson.I = $i $strVal = $oJson.StringOf("groupTypes[i]") $i = $i + 1 Wend $i = 0 $iCount_i = $oJson.SizeOfArray("proxyAddresses") While $i < $iCount_i $oJson.I = $i $strVal = $oJson.StringOf("proxyAddresses[i]") $i = $i + 1 Wend $i = 0 $iCount_i = $oJson.SizeOfArray("resourceBehaviorOptions") While $i < $iCount_i $oJson.I = $i ; ... $i = $i + 1 Wend $i = 0 $iCount_i = $oJson.SizeOfArray("resourceProvisioningOptions") While $i < $iCount_i $oJson.I = $i ; ... $i = $i + 1 Wend $i = 0 $iCount_i = $oJson.SizeOfArray("onPremisesProvisioningErrors") While $i < $iCount_i $oJson.I = $i ; ... $i = $i + 1 Wend ConsoleWrite("Success." & @CRLF) |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.