I am trying to deploy an Intune device compliance policy in my C# program. I have successfully been able to deploy a configuration profile, but a compliance policy is proving to be a tough nut to crack
Authentication to Graph is done with the graph service client, and I have gotten that to work. Permissions are also OK. Currently the app is working on my developer azure tenant.
My code is as follows:
var policyID = "ID TO MY POLICY";
var groupID = "ID TO MY GROUP";
var groupAssignmentTarget = new GroupAssignmentTarget
{ GroupId = groupID };
var policyAssignment = new DeviceCompliancePolicyAssignment
{ Target = groupAssignmentTarget };
await client.DeviceManagement.DeviceCompliancePolicies[policyID]
.Assignments
.Request()
.AddAsync(policyAssignment );
The error I am getting is
Microsoft.Graph.ServiceException: 'Code: No method match route template
Message: No OData route exists that match template ~/singleton/navigation/key/navigation with http verb POST for request /DeviceConfiguration_2306/StatelessDeviceConfigurationFEService/deviceManagement/deviceCompliancePolicies
I have verified that the groupID and policyID is valid. According to the documentation as well as github copilot x this should work. The same format is used for configuration profiles, and that does work.