為指定客戶更新設定原則
適用于:合作夥伴中心
如何更新指定客戶的指定設定原則。
必要條件
認證,如合作夥伴中心驗證所述。 此案例支援使用獨立應用程式和 App+使用者認證進行驗證。
客戶識別碼 (
customer-tenant-id
)。 如果您不知道客戶的識別碼,您可以選取 [客戶] 工作區,然後從客戶清單中選取客戶,然後從客戶清單中查閱該識別碼。 在客戶的 [帳戶] 頁面上,在 [客戶帳戶資訊] 區段中尋找Microsoft 識別碼。 Microsoft 識別碼與客戶識別碼 ()customer-tenant-id
相同。原則識別碼。
C#
若要更新指定客戶的現有設定原則,請具現化新的 ConfigurationPolicy 物件,如下列程式碼片段所示。 這個新物件中的值會取代現有 物件中的對應值。 然後,使用客戶識別碼呼叫 IAggregatePartner.Customers.ById 方法,以擷取指定客戶的作業介面。 接下來,使用原則識別碼呼叫 ConfigurationPolicies.ById 方法,以擷取指定原則之設定原則作業的介面。 最後,呼叫 Patch 或 PatchAsync 方法來更新設定原則。
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);
範例: 主控台測試應用程式。 專案:合作夥伴中心 SDK 範例 類別:UpdateConfigurationPolicy.cs
REST 要求
要求的語法
方法 | 要求 URI |
---|---|
PUT | {baseURL}/v1/customers/{customer-id}/policies/{policy-id} HTTP/1.1 |
URI 參數
建立要求時,請使用下列路徑參數。
名稱 | 類型 | 必要 | 描述 |
---|---|---|---|
customer-id | string | Yes | 用來識別客戶的 GUID 格式字串。 |
policy-id | string | Yes | 識別要更新之原則的 GUID 格式字串。 |
要求標頭
如需詳細資訊,請參閱合作夥伴中心 REST 標頭。
要求本文
要求本文必須包含提供原則資訊的物件。
名稱 | 類型 | 必要 | 可更新 | 描述 |
---|---|---|---|---|
id | string | 是 | No | 識別原則的 GUID 格式字串。 |
NAME | 字串 | Yes | Yes | 原則的易記名稱。 |
category | 字串 | 是 | No | 原則類別目錄。 |
description | 字串 | No | Yes | 原則描述。 |
devicesAssigned | 數字 | No | No | 裝置數目。 |
policySettings | 字串陣列 | Yes | Yes | 原則設定:「none」,「remove_oem_preinstalls」,「oobe_user_not_local_admin」,「skip_express_settings」,「skip _oem_registration,」skip_eula」。 |
要求範例
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 回應
如果成功,回應本文會包含新原則的 ConfigurationPolicy 資源。
回應成功和錯誤碼
每個回應都隨附 HTTP 狀態碼,會指出成功與否以及其他的偵錯資訊。 請使用網路追蹤工具來讀取此錯誤碼、錯誤類型和其他參數。 如需完整清單,請參閱合作夥伴中心的 REST 錯誤碼。
回應範例
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"
}
}