One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
In the request body, supply a JSON representation for the auditEvent object.
The following table shows the properties that are required when you create the auditEvent.
Here is an example of the request.
POST https://graph.microsoft.com/v1.0/deviceManagement/auditEvents
Content-type: application/json
Content-length: 1496
{
"@odata.type": "#microsoft.graph.auditEvent",
"displayName": "Display Name value",
"componentName": "Component Name value",
"actor": {
"@odata.type": "microsoft.graph.auditActor",
"type": "Type value",
"auditActorType": "Audit Actor Type value",
"userPermissions": [
"User Permissions value"
],
"applicationId": "Application Id value",
"applicationDisplayName": "Application Display Name value",
"userPrincipalName": "User Principal Name value",
"servicePrincipalName": "Service Principal Name value",
"ipAddress": "Ip Address value",
"userId": "User Id value"
},
"activity": "Activity value",
"activityDateTime": "2016-12-31T23:59:51.6363086-08:00",
"activityType": "Activity Type value",
"activityOperationType": "Activity Operation Type value",
"activityResult": "Activity Result value",
"correlationId": "52effe71-fe71-52ef-71fe-ef5271feef52",
"resources": [
{
"@odata.type": "microsoft.graph.auditResource",
"displayName": "Display Name value",
"modifiedProperties": [
{
"@odata.type": "microsoft.graph.auditProperty",
"displayName": "Display Name value",
"oldValue": "Old Value value",
"newValue": "New Value value"
}
],
"type": "Type value",
"auditResourceType": "Audit Resource Type value",
"resourceId": "Resource Id value"
}
],
"category": "Category value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AuditEvent
{
OdataType = "#microsoft.graph.auditEvent",
DisplayName = "Display Name value",
ComponentName = "Component Name value",
Actor = new AuditActor
{
OdataType = "microsoft.graph.auditActor",
AuditActorType = "Audit Actor Type value",
UserPermissions = new List<string>
{
"User Permissions value",
},
ApplicationId = "Application Id value",
ApplicationDisplayName = "Application Display Name value",
UserPrincipalName = "User Principal Name value",
ServicePrincipalName = "Service Principal Name value",
IpAddress = "Ip Address value",
UserId = "User Id value",
AdditionalData = new Dictionary<string, object>
{
{
"type" , "Type value"
},
},
},
Activity = "Activity value",
ActivityDateTime = DateTimeOffset.Parse("2016-12-31T23:59:51.6363086-08:00"),
ActivityType = "Activity Type value",
ActivityOperationType = "Activity Operation Type value",
ActivityResult = "Activity Result value",
CorrelationId = Guid.Parse("52effe71-fe71-52ef-71fe-ef5271feef52"),
Resources = new List<AuditResource>
{
new AuditResource
{
OdataType = "microsoft.graph.auditResource",
DisplayName = "Display Name value",
ModifiedProperties = new List<AuditProperty>
{
new AuditProperty
{
OdataType = "microsoft.graph.auditProperty",
DisplayName = "Display Name value",
OldValue = "Old Value value",
NewValue = "New Value value",
},
},
AuditResourceType = "Audit Resource Type value",
ResourceId = "Resource Id value",
AdditionalData = new Dictionary<string, object>
{
{
"type" , "Type value"
},
},
},
},
Category = "Category value",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.AuditEvents.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc device-management audit-events create --body '{\
"@odata.type": "#microsoft.graph.auditEvent",\
"displayName": "Display Name value",\
"componentName": "Component Name value",\
"actor": {\
"@odata.type": "microsoft.graph.auditActor",\
"type": "Type value",\
"auditActorType": "Audit Actor Type value",\
"userPermissions": [\
"User Permissions value"\
],\
"applicationId": "Application Id value",\
"applicationDisplayName": "Application Display Name value",\
"userPrincipalName": "User Principal Name value",\
"servicePrincipalName": "Service Principal Name value",\
"ipAddress": "Ip Address value",\
"userId": "User Id value"\
},\
"activity": "Activity value",\
"activityDateTime": "2016-12-31T23:59:51.6363086-08:00",\
"activityType": "Activity Type value",\
"activityOperationType": "Activity Operation Type value",\
"activityResult": "Activity Result value",\
"correlationId": "52effe71-fe71-52ef-71fe-ef5271feef52",\
"resources": [\
{\
"@odata.type": "microsoft.graph.auditResource",\
"displayName": "Display Name value",\
"modifiedProperties": [\
{\
"@odata.type": "microsoft.graph.auditProperty",\
"displayName": "Display Name value",\
"oldValue": "Old Value value",\
"newValue": "New Value value"\
}\
],\
"type": "Type value",\
"auditResourceType": "Audit Resource Type value",\
"resourceId": "Resource Id value"\
}\
],\
"category": "Category value"\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
"time"
"github.com/google/uuid"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAuditEvent()
displayName := "Display Name value"
requestBody.SetDisplayName(&displayName)
componentName := "Component Name value"
requestBody.SetComponentName(&componentName)
actor := graphmodels.NewAuditActor()
auditActorType := "Audit Actor Type value"
actor.SetAuditActorType(&auditActorType)
userPermissions := []string {
"User Permissions value",
}
actor.SetUserPermissions(userPermissions)
applicationId := "Application Id value"
actor.SetApplicationId(&applicationId)
applicationDisplayName := "Application Display Name value"
actor.SetApplicationDisplayName(&applicationDisplayName)
userPrincipalName := "User Principal Name value"
actor.SetUserPrincipalName(&userPrincipalName)
servicePrincipalName := "Service Principal Name value"
actor.SetServicePrincipalName(&servicePrincipalName)
ipAddress := "Ip Address value"
actor.SetIpAddress(&ipAddress)
userId := "User Id value"
actor.SetUserId(&userId)
additionalData := map[string]interface{}{
"type" : "Type value",
}
actor.SetAdditionalData(additionalData)
requestBody.SetActor(actor)
activity := "Activity value"
requestBody.SetActivity(&activity)
activityDateTime , err := time.Parse(time.RFC3339, "2016-12-31T23:59:51.6363086-08:00")
requestBody.SetActivityDateTime(&activityDateTime)
activityType := "Activity Type value"
requestBody.SetActivityType(&activityType)
activityOperationType := "Activity Operation Type value"
requestBody.SetActivityOperationType(&activityOperationType)
activityResult := "Activity Result value"
requestBody.SetActivityResult(&activityResult)
correlationId := uuid.MustParse("52effe71-fe71-52ef-71fe-ef5271feef52")
requestBody.SetCorrelationId(&correlationId)
auditResource := graphmodels.NewAuditResource()
displayName := "Display Name value"
auditResource.SetDisplayName(&displayName)
auditProperty := graphmodels.NewAuditProperty()
displayName := "Display Name value"
auditProperty.SetDisplayName(&displayName)
oldValue := "Old Value value"
auditProperty.SetOldValue(&oldValue)
newValue := "New Value value"
auditProperty.SetNewValue(&newValue)
modifiedProperties := []graphmodels.AuditPropertyable {
auditProperty,
}
auditResource.SetModifiedProperties(modifiedProperties)
auditResourceType := "Audit Resource Type value"
auditResource.SetAuditResourceType(&auditResourceType)
resourceId := "Resource Id value"
auditResource.SetResourceId(&resourceId)
additionalData := map[string]interface{}{
"type" : "Type value",
}
auditResource.SetAdditionalData(additionalData)
resources := []graphmodels.AuditResourceable {
auditResource,
}
requestBody.SetResources(resources)
category := "Category value"
requestBody.SetCategory(&category)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
auditEvents, err := graphClient.DeviceManagement().AuditEvents().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AuditEvent auditEvent = new AuditEvent();
auditEvent.setOdataType("#microsoft.graph.auditEvent");
auditEvent.setDisplayName("Display Name value");
auditEvent.setComponentName("Component Name value");
AuditActor actor = new AuditActor();
actor.setOdataType("microsoft.graph.auditActor");
actor.setAuditActorType("Audit Actor Type value");
LinkedList<String> userPermissions = new LinkedList<String>();
userPermissions.add("User Permissions value");
actor.setUserPermissions(userPermissions);
actor.setApplicationId("Application Id value");
actor.setApplicationDisplayName("Application Display Name value");
actor.setUserPrincipalName("User Principal Name value");
actor.setServicePrincipalName("Service Principal Name value");
actor.setIpAddress("Ip Address value");
actor.setUserId("User Id value");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("type", "Type value");
actor.setAdditionalData(additionalData);
auditEvent.setActor(actor);
auditEvent.setActivity("Activity value");
OffsetDateTime activityDateTime = OffsetDateTime.parse("2016-12-31T23:59:51.6363086-08:00");
auditEvent.setActivityDateTime(activityDateTime);
auditEvent.setActivityType("Activity Type value");
auditEvent.setActivityOperationType("Activity Operation Type value");
auditEvent.setActivityResult("Activity Result value");
auditEvent.setCorrelationId(UUID.fromString("52effe71-fe71-52ef-71fe-ef5271feef52"));
LinkedList<AuditResource> resources = new LinkedList<AuditResource>();
AuditResource auditResource = new AuditResource();
auditResource.setOdataType("microsoft.graph.auditResource");
auditResource.setDisplayName("Display Name value");
LinkedList<AuditProperty> modifiedProperties = new LinkedList<AuditProperty>();
AuditProperty auditProperty = new AuditProperty();
auditProperty.setOdataType("microsoft.graph.auditProperty");
auditProperty.setDisplayName("Display Name value");
auditProperty.setOldValue("Old Value value");
auditProperty.setNewValue("New Value value");
modifiedProperties.add(auditProperty);
auditResource.setModifiedProperties(modifiedProperties);
auditResource.setAuditResourceType("Audit Resource Type value");
auditResource.setResourceId("Resource Id value");
HashMap<String, Object> additionalData1 = new HashMap<String, Object>();
additionalData1.put("type", "Type value");
auditResource.setAdditionalData(additionalData1);
resources.add(auditResource);
auditEvent.setResources(resources);
auditEvent.setCategory("Category value");
AuditEvent result = graphClient.deviceManagement().auditEvents().post(auditEvent);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const auditEvent = {
'@odata.type': '#microsoft.graph.auditEvent',
displayName: 'Display Name value',
componentName: 'Component Name value',
actor: {
'@odata.type': 'microsoft.graph.auditActor',
type: 'Type value',
auditActorType: 'Audit Actor Type value',
userPermissions: [
'User Permissions value'
],
applicationId: 'Application Id value',
applicationDisplayName: 'Application Display Name value',
userPrincipalName: 'User Principal Name value',
servicePrincipalName: 'Service Principal Name value',
ipAddress: 'Ip Address value',
userId: 'User Id value'
},
activity: 'Activity value',
activityDateTime: '2016-12-31T23:59:51.6363086-08:00',
activityType: 'Activity Type value',
activityOperationType: 'Activity Operation Type value',
activityResult: 'Activity Result value',
correlationId: '52effe71-fe71-52ef-71fe-ef5271feef52',
resources: [
{
'@odata.type': 'microsoft.graph.auditResource',
displayName: 'Display Name value',
modifiedProperties: [
{
'@odata.type': 'microsoft.graph.auditProperty',
displayName: 'Display Name value',
oldValue: 'Old Value value',
newValue: 'New Value value'
}
],
type: 'Type value',
auditResourceType: 'Audit Resource Type value',
resourceId: 'Resource Id value'
}
],
category: 'Category value'
};
await client.api('/deviceManagement/auditEvents')
.post(auditEvent);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AuditEvent;
use Microsoft\Graph\Generated\Models\AuditActor;
use Microsoft\Graph\Generated\Models\AuditResource;
use Microsoft\Graph\Generated\Models\AuditProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AuditEvent();
$requestBody->setOdataType('#microsoft.graph.auditEvent');
$requestBody->setDisplayName('Display Name value');
$requestBody->setComponentName('Component Name value');
$actor = new AuditActor();
$actor->setOdataType('microsoft.graph.auditActor');
$actor->setAuditActorType('Audit Actor Type value');
$actor->setUserPermissions(['User Permissions value', ]);
$actor->setApplicationId('Application Id value');
$actor->setApplicationDisplayName('Application Display Name value');
$actor->setUserPrincipalName('User Principal Name value');
$actor->setServicePrincipalName('Service Principal Name value');
$actor->setIpAddress('Ip Address value');
$actor->setUserId('User Id value');
$additionalData = [
'type' => 'Type value',
];
$actor->setAdditionalData($additionalData);
$requestBody->setActor($actor);
$requestBody->setActivity('Activity value');
$requestBody->setActivityDateTime(new \DateTime('2016-12-31T23:59:51.6363086-08:00'));
$requestBody->setActivityType('Activity Type value');
$requestBody->setActivityOperationType('Activity Operation Type value');
$requestBody->setActivityResult('Activity Result value');
$requestBody->setCorrelationId('52effe71-fe71-52ef-71fe-ef5271feef52');
$resourcesAuditResource1 = new AuditResource();
$resourcesAuditResource1->setOdataType('microsoft.graph.auditResource');
$resourcesAuditResource1->setDisplayName('Display Name value');
$modifiedPropertiesAuditProperty1 = new AuditProperty();
$modifiedPropertiesAuditProperty1->setOdataType('microsoft.graph.auditProperty');
$modifiedPropertiesAuditProperty1->setDisplayName('Display Name value');
$modifiedPropertiesAuditProperty1->setOldValue('Old Value value');
$modifiedPropertiesAuditProperty1->setNewValue('New Value value');
$modifiedPropertiesArray []= $modifiedPropertiesAuditProperty1;
$resourcesAuditResource1->setModifiedProperties($modifiedPropertiesArray);
$resourcesAuditResource1->setAuditResourceType('Audit Resource Type value');
$resourcesAuditResource1->setResourceId('Resource Id value');
$additionalData = [
'type' => 'Type value',
];
$resourcesAuditResource1->setAdditionalData($additionalData);
$resourcesArray []= $resourcesAuditResource1;
$requestBody->setResources($resourcesArray);
$requestBody->setCategory('Category value');
$result = $graphServiceClient->deviceManagement()->auditEvents()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.DeviceManagement.Administration
$params = @{
"@odata.type" = "#microsoft.graph.auditEvent"
displayName = "Display Name value"
componentName = "Component Name value"
actor = @{
"@odata.type" = "microsoft.graph.auditActor"
type = "Type value"
auditActorType = "Audit Actor Type value"
userPermissions = @(
"User Permissions value"
)
applicationId = "Application Id value"
applicationDisplayName = "Application Display Name value"
userPrincipalName = "User Principal Name value"
servicePrincipalName = "Service Principal Name value"
ipAddress = "Ip Address value"
userId = "User Id value"
}
activity = "Activity value"
activityDateTime = [System.DateTime]::Parse("2016-12-31T23:59:51.6363086-08:00")
activityType = "Activity Type value"
activityOperationType = "Activity Operation Type value"
activityResult = "Activity Result value"
correlationId = "52effe71-fe71-52ef-71fe-ef5271feef52"
resources = @(
@{
"@odata.type" = "microsoft.graph.auditResource"
displayName = "Display Name value"
modifiedProperties = @(
@{
"@odata.type" = "microsoft.graph.auditProperty"
displayName = "Display Name value"
oldValue = "Old Value value"
newValue = "New Value value"
}
)
type = "Type value"
auditResourceType = "Audit Resource Type value"
resourceId = "Resource Id value"
}
)
category = "Category value"
}
New-MgDeviceManagementAuditEvent -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.audit_event import AuditEvent
from msgraph.generated.models.audit_actor import AuditActor
from msgraph.generated.models.audit_resource import AuditResource
from msgraph.generated.models.audit_property import AuditProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AuditEvent(
odata_type = "#microsoft.graph.auditEvent",
display_name = "Display Name value",
component_name = "Component Name value",
actor = AuditActor(
odata_type = "microsoft.graph.auditActor",
audit_actor_type = "Audit Actor Type value",
user_permissions = [
"User Permissions value",
],
application_id = "Application Id value",
application_display_name = "Application Display Name value",
user_principal_name = "User Principal Name value",
service_principal_name = "Service Principal Name value",
ip_address = "Ip Address value",
user_id = "User Id value",
additional_data = {
"type" : "Type value",
}
),
activity = "Activity value",
activity_date_time = "2016-12-31T23:59:51.6363086-08:00",
activity_type = "Activity Type value",
activity_operation_type = "Activity Operation Type value",
activity_result = "Activity Result value",
correlation_id = UUID("52effe71-fe71-52ef-71fe-ef5271feef52"),
resources = [
AuditResource(
odata_type = "microsoft.graph.auditResource",
display_name = "Display Name value",
modified_properties = [
AuditProperty(
odata_type = "microsoft.graph.auditProperty",
display_name = "Display Name value",
old_value = "Old Value value",
new_value = "New Value value",
),
],
audit_resource_type = "Audit Resource Type value",
resource_id = "Resource Id value",
additional_data = {
"type" : "Type value",
}
),
],
category = "Category value",
)
result = await graph_client.device_management.audit_events.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.