POST https://graph.microsoft.com/v1.0/security/labels/departments
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.security.departmentTemplate",
"displayName": "Finance",
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models.Security;
var requestBody = new DepartmentTemplate
{
OdataType = "#microsoft.graph.security.departmentTemplate",
DisplayName = "Finance",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.Labels.Departments.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodelssecurity "github.com/microsoftgraph/msgraph-sdk-go/models/security"
//other-imports
)
requestBody := graphmodelssecurity.NewDepartmentTemplate()
displayName := "Finance"
requestBody.SetDisplayName(&displayName)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
departments, err := graphClient.Security().Labels().Departments().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.models.security.DepartmentTemplate departmentTemplate = new com.microsoft.graph.models.security.DepartmentTemplate();
departmentTemplate.setOdataType("#microsoft.graph.security.departmentTemplate");
departmentTemplate.setDisplayName("Finance");
com.microsoft.graph.models.security.DepartmentTemplate result = graphClient.security().labels().departments().post(departmentTemplate);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Security\DepartmentTemplate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DepartmentTemplate();
$requestBody->setOdataType('#microsoft.graph.security.departmentTemplate');
$requestBody->setDisplayName('Finance');
$result = $graphServiceClient->security()->labels()->departments()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.security.department_template import DepartmentTemplate
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DepartmentTemplate(
odata_type = "#microsoft.graph.security.departmentTemplate",
display_name = "Finance",
)
result = await graph_client.security.labels.departments.post(request_body)