How can I create a DeviceManagementCompliancePolicy?

Andrei Shchetkin 0 Reputation points
2024-04-05T07:00:58.8033333+00:00

Hi everyone!
I'm trying to create a deviceManagementCompliancePolicy by graph api explorer. Just want to figure out what is it. But I get error response with code "FeatureNotEnabled". How can I enable it or where can I find some docs about this type of policies?

All information that I found is this resource description. Also if I trying to create this type using .Net graph SDK v5.6 it has no @odata.type property as well. Seems as some not implemented functional.

Note: I have enough granted permissions.

My request: POST https://graph.microsoft.com/beta/deviceManagement/compliancePolicies
Body:

{
    "@odata.type": "#microsoft.graph.deviceManagementCompliancePolicy",
    "name": "Name value",
    "description": "Description value",
    "platforms": "windows10",
    "technologies": "mdm",
    "settingCount": 1,
    "creationSource": "Creation Source value",
    "roleScopeTagIds": [],
    "isAssigned": true,
    "settings": [
        {
            "settingInstance": {
                "@odata.type": "#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance",
                "settingDefinitionId": "definition-id",
                "groupSettingCollectionValue": [
                    {
                        "@odata.type": "#microsoft.graph.deviceManagementConfigurationGroupSettingValue"
                    }
                ]
            }
        }
    ]
}

Response with 403 status code and body:

{
    "error": {
        "code": "FeatureNotEnabled",
        "message": "{  \"_version\": 3,  \"Message\": \"An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 7c34ceb4-4ced-030c-a1f1-15d986cbe076 - Url: https://fef.amsua0102.manage.microsoft.com/DeviceConfigV2/DCV2GraphService/de147310-ffff-2561-0302-040421532621/deviceManagement/compliancePolicies?api-version=5024-01-18\",  \"CustomApiErrorPhrase\": \"\",  \"RetryAfter\": null,  \"ErrorSourceService\": \"\",  \"HttpHeaders\": \"{}\"}",
        "innerError": {
            "date": "2024-04-05T06:38:18",
            "request-id": "04480fc0-a398-4b10-bf4a-a78e2c58c3bc",
            "client-request-id": "7c34ceb4-4ced-030c-a1f1-15d986cbe076"
        }
    }
}
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,015 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
5,061 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 48,591 Reputation points Microsoft Vendor
    2024-04-08T01:42:02.9433333+00:00

    @Andrei Shchetkin, Thanks for posting in Q&A. From the document, I find the settings property is not under this API. I think this can be the reason we received "FeatureNotEnabled" error.

    It seems you are creating windows 10 compliance policy. After researching, I find a doc for this.

    https://learn.microsoft.com/en-us/graph/api/intune-deviceconfig-windows10compliancepolicy-create?view=graph-rest-1.0&tabs=http

    Meanwhile, I also find a script this. You can also read to see if it can help.

    https://www.powershellgallery.com/packages/MSGraphFunctions/2.0.1/Content/Public%5CNew-GraphDeviceCompliancePolicy.ps1

    Hope the information can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.