Compliance status of the policy report. Possible values are: unknown, notApplicable, compliant, remediated, nonCompliant, error, conflict, notAssigned.
lastReportedDateTime
DateTimeOffset
Last modified date time of the policy report.
userPrincipalName
String
UserPrincipalName.
Response
If successful, this method returns a 201 Created response code and a deviceComplianceDeviceStatus object in the response body.
POST https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/deviceStatuses
Content-type: application/json
Content-length: 426
{
"@odata.type": "#microsoft.graph.deviceComplianceDeviceStatus",
"deviceDisplayName": "Device Display Name value",
"userName": "User Name value",
"deviceModel": "Device Model value",
"complianceGracePeriodExpirationDateTime": "2016-12-31T23:56:44.951111-08:00",
"status": "notApplicable",
"lastReportedDateTime": "2017-01-01T00:00:17.7769392-08:00",
"userPrincipalName": "User Principal Name value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DeviceComplianceDeviceStatus
{
OdataType = "#microsoft.graph.deviceComplianceDeviceStatus",
DeviceDisplayName = "Device Display Name value",
UserName = "User Name value",
DeviceModel = "Device Model value",
ComplianceGracePeriodExpirationDateTime = DateTimeOffset.Parse("2016-12-31T23:56:44.951111-08:00"),
Status = ComplianceStatus.NotApplicable,
LastReportedDateTime = DateTimeOffset.Parse("2017-01-01T00:00:17.7769392-08:00"),
UserPrincipalName = "User Principal Name 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.DeviceCompliancePolicies["{deviceCompliancePolicy-id}"].DeviceStatuses.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDeviceComplianceDeviceStatus()
deviceDisplayName := "Device Display Name value"
requestBody.SetDeviceDisplayName(&deviceDisplayName)
userName := "User Name value"
requestBody.SetUserName(&userName)
deviceModel := "Device Model value"
requestBody.SetDeviceModel(&deviceModel)
complianceGracePeriodExpirationDateTime , err := time.Parse(time.RFC3339, "2016-12-31T23:56:44.951111-08:00")
requestBody.SetComplianceGracePeriodExpirationDateTime(&complianceGracePeriodExpirationDateTime)
status := graphmodels.NOTAPPLICABLE_COMPLIANCESTATUS
requestBody.SetStatus(&status)
lastReportedDateTime , err := time.Parse(time.RFC3339, "2017-01-01T00:00:17.7769392-08:00")
requestBody.SetLastReportedDateTime(&lastReportedDateTime)
userPrincipalName := "User Principal Name value"
requestBody.SetUserPrincipalName(&userPrincipalName)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
deviceStatuses, err := graphClient.DeviceManagement().DeviceCompliancePolicies().ByDeviceCompliancePolicyId("deviceCompliancePolicy-id").DeviceStatuses().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceComplianceDeviceStatus deviceComplianceDeviceStatus = new DeviceComplianceDeviceStatus();
deviceComplianceDeviceStatus.setOdataType("#microsoft.graph.deviceComplianceDeviceStatus");
deviceComplianceDeviceStatus.setDeviceDisplayName("Device Display Name value");
deviceComplianceDeviceStatus.setUserName("User Name value");
deviceComplianceDeviceStatus.setDeviceModel("Device Model value");
OffsetDateTime complianceGracePeriodExpirationDateTime = OffsetDateTime.parse("2016-12-31T23:56:44.951111-08:00");
deviceComplianceDeviceStatus.setComplianceGracePeriodExpirationDateTime(complianceGracePeriodExpirationDateTime);
deviceComplianceDeviceStatus.setStatus(ComplianceStatus.NotApplicable);
OffsetDateTime lastReportedDateTime = OffsetDateTime.parse("2017-01-01T00:00:17.7769392-08:00");
deviceComplianceDeviceStatus.setLastReportedDateTime(lastReportedDateTime);
deviceComplianceDeviceStatus.setUserPrincipalName("User Principal Name value");
DeviceComplianceDeviceStatus result = graphClient.deviceManagement().deviceCompliancePolicies().byDeviceCompliancePolicyId("{deviceCompliancePolicy-id}").deviceStatuses().post(deviceComplianceDeviceStatus);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DeviceComplianceDeviceStatus;
use Microsoft\Graph\Generated\Models\ComplianceStatus;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceComplianceDeviceStatus();
$requestBody->setOdataType('#microsoft.graph.deviceComplianceDeviceStatus');
$requestBody->setDeviceDisplayName('Device Display Name value');
$requestBody->setUserName('User Name value');
$requestBody->setDeviceModel('Device Model value');
$requestBody->setComplianceGracePeriodExpirationDateTime(new \DateTime('2016-12-31T23:56:44.951111-08:00'));
$requestBody->setStatus(new ComplianceStatus('notApplicable'));
$requestBody->setLastReportedDateTime(new \DateTime('2017-01-01T00:00:17.7769392-08:00'));
$requestBody->setUserPrincipalName('User Principal Name value');
$result = $graphServiceClient->deviceManagement()->deviceCompliancePolicies()->byDeviceCompliancePolicyId('deviceCompliancePolicy-id')->deviceStatuses()->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.device_compliance_device_status import DeviceComplianceDeviceStatus
from msgraph.generated.models.compliance_status import ComplianceStatus
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceComplianceDeviceStatus(
odata_type = "#microsoft.graph.deviceComplianceDeviceStatus",
device_display_name = "Device Display Name value",
user_name = "User Name value",
device_model = "Device Model value",
compliance_grace_period_expiration_date_time = "2016-12-31T23:56:44.951111-08:00",
status = ComplianceStatus.NotApplicable,
last_reported_date_time = "2017-01-01T00:00:17.7769392-08:00",
user_principal_name = "User Principal Name value",
)
result = await graph_client.device_management.device_compliance_policies.by_device_compliance_policy_id('deviceCompliancePolicy-id').device_statuses.post(request_body)
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.
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 475
{
"@odata.type": "#microsoft.graph.deviceComplianceDeviceStatus",
"id": "c6c78124-8124-c6c7-2481-c7c62481c7c6",
"deviceDisplayName": "Device Display Name value",
"userName": "User Name value",
"deviceModel": "Device Model value",
"complianceGracePeriodExpirationDateTime": "2016-12-31T23:56:44.951111-08:00",
"status": "notApplicable",
"lastReportedDateTime": "2017-01-01T00:00:17.7769392-08:00",
"userPrincipalName": "User Principal Name value"
}