Jaa


Update a configuration policy for the specified customer

Applies to: Partner Center

How to update the specified configuration policy for the specified customer.

Prerequisites

  • Credentials as described in Partner Center authentication. This scenario supports authentication with both standalone App and App+User credentials.

  • A customer ID (customer-tenant-id). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer's Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id).

  • The policy identifier.

C#

To update an existing configuration policy for the specified customer, instantiate a new ConfigurationPolicy object as shown in the following code snippet. The values in this new object replace the corresponding values in the existing object. Then, call the IAggregatePartner.Customers.ById method with the customer ID to retrieve an interface to operations on the specified customer. Next, call the ConfigurationPolicies.ById method with the policy ID to retrieve an interface to configuration policy operations for the specified policy. Finally, call the Patch or PatchAsync method to update the configuration policy.

IAggregatePartner partnerOperations;
string selectedCustomerId;
string selectedConfigurationPolicyId;

ConfigurationPolicy configPolicyToBeUpdated = new ConfigurationPolicy()
{
    Name= "Test Config Policy",
    Id = selectedConfigurationPolicyId,
    PolicySettings = new List<PolicySettingsType>() {
        PolicySettingsType.OobeUserNotLocalAdmin,
        PolicySettingsType.RemoveOemPreinstalls }
};

ConfigurationPolicy updatedConfigurationPolicy =
    partnerOperations.Customers.ById(selectedCustomerId).ConfigurationPolicies.ById(selectedConfigurationPolicyId).Patch(configPolicyToBeUpdated);

Sample: Console test app. Project: Partner Center SDK Samples Class: UpdateConfigurationPolicy.cs

REST request

Request syntax

Method Request URI
PUT {baseURL}/v1/customers/{customer-id}/policies/{policy-id} HTTP/1.1

URI parameter

Use the following path parameters when creating the request.

Name Type Required Description
customer-id string Yes A GUID-formatted string that identifies the customer.
policy-id string Yes A GUID-formatted string that identifies the policy to update.

Request headers

For more information, see Partner Center REST headers.

Request body

The request body must contain an object that provides the policy information.

Name Type Required Updatable Description
id string Yes No The GUID-formatted string that identifies the policy.
name string Yes Yes The friendly name of the policy.
category string Yes No The policy category.
description string No Yes The policy description.
devicesAssigned number No No The number of devices.
policySettings array of strings Yes Yes The policy settings: "none","remove_oem_preinstalls","oobe_user_not_local_admin","skip_express_settings","skip _oem_registration,"skip_eula".

Request example

PUT https://api.partnercenter.microsoft.com/v1/customers/47021739-3426-40bf-9601-61b4b6d7c793/policies/56edf752-ee77-4fd8-b7f5-df1f74a3a9ac HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: e88d014d-ab70-41de-90a0-f7fd1797267d
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Content-Length: 256
Content-Type: application/json
Host: api.partnercenter.microsoft.com

{
    "id": "56edf752-ee77-4fd8-b7f5-df1f74a3a9ac",
    "name": "Windows test policy",
    "category": "o_o_b_e",
    "description": "Test policy creation from API",
    "devicesAssigned": 0,
    "policySettings": ["skip_express_settings"]
}

REST response

If successful, the response body contains the ConfigurationPolicy resource for the new policy.

Response success and error codes

Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For the full list, see Partner Center REST error codes.

Response example

HTTP/1.1 200 OK
Content-Length: 421
Content-Type: application/json; charset=utf-8
MS-CorrelationId: bbbb1111-cc22-3333-44dd-555555eeeeee
MS-RequestId: cb1fa1f3-1381-45d9-99c5-511e5d3efa7c
MS-CV: YrLe3w6BbUSMt1fi.0
MS-ServerId: 030020344
Date: Tue, 25 Jul 2017 18:10:29 GMT

{
    "id": "56edf752-ee77-4fd8-b7f5-df1f74a3a9ac",
    "name": "Windows test policy",
    "category": "o_o_b_e",
    "description": "Test policy creation from API",
    "devicesAssigned": 0,
    "policySettings": ["skip_express_settings"],
    "createdDate": "2017-01-01T00:00:00",
    "lastModifiedDate": "2017-07-25T18:10:15",
    "attributes": {
        "objectType": "ConfigurationPolicy"
    }
}