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
(PowerBuilder) 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.
integer li_rc oleobject loo_Http oleobject loo_JsonToken integer li_Success oleobject loo_Json oleobject loo_Resp string ls_Id string ls_DeletedDateTime string ls_Classification string ls_CreatedDateTime string ls_Description string ls_DisplayName string ls_Mail integer li_MailEnabled string ls_MailNickname string ls_OnPremisesLastSyncDateTime string ls_OnPremisesSecurityIdentifier string ls_OnPremisesSyncEnabled string ls_PreferredDataLocation string ls_RenewedDateTime integer li_SecurityEnabled string ls_Visibility integer i integer li_Count_i string ls_StrVal // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Use your previously obtained access token as shown here: // Get Microsoft Graph OAuth2 Access Token with Group.ReadWrite.All scope. loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/msGraphGroup.json") if li_Success = 0 then Write-Debug loo_JsonToken.LastErrorText destroy loo_Http destroy loo_JsonToken return end if loo_Http.AuthToken = loo_JsonToken.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 // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("description","Self help community for library") loo_Json.UpdateString("displayName","Library Assist") loo_Json.UpdateString("groupTypes[0]","Unified") loo_Json.UpdateBool("mailEnabled",1) loo_Json.UpdateString("mailNickname","library") loo_Json.UpdateBool("securityEnabled",0) // POST the JSON to https://graph.microsoft.com/v1.0/groups loo_Resp = loo_Http.PostJson3("https://graph.microsoft.com/v1.0/groups","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_JsonToken destroy loo_Json return end if loo_Json.Load(loo_Resp.BodyStr) loo_Json.EmitCompact = 0 if loo_Resp.StatusCode <> 201 then Write-Debug loo_Json.Emit() Write-Debug "Failed, response status code = " + string(loo_Resp.StatusCode) destroy loo_Resp destroy loo_Http destroy loo_JsonToken destroy loo_Json return end if destroy loo_Resp Write-Debug loo_Json.Emit() // 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 ls_Id = loo_Json.StringOf("id") ls_DeletedDateTime = loo_Json.StringOf("deletedDateTime") ls_Classification = loo_Json.StringOf("classification") ls_CreatedDateTime = loo_Json.StringOf("createdDateTime") ls_Description = loo_Json.StringOf("description") ls_DisplayName = loo_Json.StringOf("displayName") ls_Mail = loo_Json.StringOf("mail") li_MailEnabled = loo_Json.BoolOf("mailEnabled") ls_MailNickname = loo_Json.StringOf("mailNickname") ls_OnPremisesLastSyncDateTime = loo_Json.StringOf("onPremisesLastSyncDateTime") ls_OnPremisesSecurityIdentifier = loo_Json.StringOf("onPremisesSecurityIdentifier") ls_OnPremisesSyncEnabled = loo_Json.StringOf("onPremisesSyncEnabled") ls_PreferredDataLocation = loo_Json.StringOf("preferredDataLocation") ls_RenewedDateTime = loo_Json.StringOf("renewedDateTime") li_SecurityEnabled = loo_Json.BoolOf("securityEnabled") ls_Visibility = loo_Json.StringOf("visibility") i = 0 li_Count_i = loo_Json.SizeOfArray("creationOptions") do while i < li_Count_i loo_Json.I = i i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("groupTypes") do while i < li_Count_i loo_Json.I = i ls_StrVal = loo_Json.StringOf("groupTypes[i]") i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("proxyAddresses") do while i < li_Count_i loo_Json.I = i ls_StrVal = loo_Json.StringOf("proxyAddresses[i]") i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("resourceBehaviorOptions") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("resourceProvisioningOptions") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("onPremisesProvisioningErrors") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop Write-Debug "Success." destroy loo_Http destroy loo_JsonToken destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.