Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models.Security;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new RetentionEvent
{
OdataType = "#microsoft.graph.security.retentionEvent",
DisplayName = "String",
Description = "String",
EventTriggerDateTime = DateTimeOffset.Parse("String (timestamp)"),
AdditionalData = new Dictionary<string, object>
{
{
"eventQuery" , new List<object>
{
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"@odata.type", new UntypedString("microsoft.graph.security.eventQuery")
},
}),
}
},
{
"retentionEventType@odata.bind" , "https://graph.microsoft.com/v1.0/security/triggerTypes/retentionEventType/9eecef97-fb3c-4c68-825b-4dd74530863a"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.Triggers.RetentionEvents.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.models.security.RetentionEvent retentionEvent = new com.microsoft.graph.models.security.RetentionEvent();
retentionEvent.setOdataType("#microsoft.graph.security.retentionEvent");
retentionEvent.setDisplayName("String");
retentionEvent.setDescription("String");
OffsetDateTime eventTriggerDateTime = OffsetDateTime.parse("String (timestamp)");
retentionEvent.setEventTriggerDateTime(eventTriggerDateTime);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<Object> eventQuery = new LinkedList<Object>();
property = new ();
property.setOdataType("microsoft.graph.security.eventQuery");
eventQuery.add(property);
additionalData.put("eventQuery", eventQuery);
additionalData.put("retentionEventType@odata.bind", "https://graph.microsoft.com/v1.0/security/triggerTypes/retentionEventType/9eecef97-fb3c-4c68-825b-4dd74530863a");
retentionEvent.setAdditionalData(additionalData);
com.microsoft.graph.models.security.RetentionEvent result = graphClient.security().triggers().retentionEvents().post(retentionEvent);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.security.retention_event import RetentionEvent
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = RetentionEvent(
odata_type = "#microsoft.graph.security.retentionEvent",
display_name = "String",
description = "String",
event_trigger_date_time = "String (timestamp)",
additional_data = {
"event_query" : [
{
"@odata_type" : "microsoft.graph.security.eventQuery",
},
],
"retention_event_type@odata_bind" : "https://graph.microsoft.com/v1.0/security/triggerTypes/retentionEventType/9eecef97-fb3c-4c68-825b-4dd74530863a",
}
)
result = await graph_client.security.triggers.retention_events.post(request_body)