按ID更新訂閱

適用於:合作夥伴中心 |由 21Vianet 營運的合作夥伴中心 |美國政府Microsoft雲端合作夥伴中心

按ID更新 訂閱 。

在合作夥伴中心,首先 選擇一個客戶來執行此作。 然後,選擇要更新的相關訂閱。 要完成作,請更改所需的值,然後選擇 Submit。

先決條件

  • 合作夥伴中心身份驗證中所述的憑證。 此案例支援使用獨立應用程式和 App+使用者認證進行驗證。

  • 客戶識別碼 (customer-tenant-id)。 如果您不知道客戶的標識碼,您可以在 合作夥伴中心 中選取 [客戶] 工作區,然後從客戶清單中找到該客戶,接著選取 [帳戶]。 在客戶的 [帳戶] 頁面上,在 [客戶帳戶資訊] 區段中尋找 Microsoft ID。 Microsoft ID 與客戶 ID (customer-tenant-id) 相同。

  • 訂用帳戶標識碼。

C#

要更新客戶訂閱的值,請先 獲取訂閱,然後更改訂閱的所需屬性。 變更之後,請使用您的 IAggregatePartner.Customers 集合,並呼叫 ById() 方法。 然後呼叫 Subscriptions 屬性,後面接著 ById() 方法。 然後,藉由呼叫 Patch() 方法來完成。

// IAggregatePartner partnerOperations;
// var customerId;
// var subscriptionId;

//retrieving the subscription, for the purpose of the sample
ResourceCollection<Subscription> customerSubscriptions = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.Get();
Subscription selectedSubscription = customerSubscriptions.Items.FirstOrDefault(sub => sub.Status == SubscriptionStatus.Active);

//update selected subscription; a variety of fields can be updated, but quantity is used as an example below
selectedSubscription.Quantity++;

var updatedSubscription = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(selectedSubscription.Id).Patch(selectedSubscription);

範例: 控制台測試應用程式。 專案:PartnerSDK.FeatureSample 類別:UpdateSubscription.cs

REST 要求

請求語法

方法 請求網址識別碼 (URI)
補丁 {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id} HTTP/1.1

URI 參數

下表列出了更新訂閱所需的查詢參數。

名稱 類型 為必填項目 說明
客戶租戶識別碼 (customer-tenant-id) 全域唯一識別碼 (GUID) 是 與客戶對應的 GUID。
訂閱ID 全域唯一識別碼 (GUID) 是 與訂閱對應的 GUID。

請求標頭

如需詳細資訊,請參閱合作夥伴中心 REST 標頭。

請求主體

請求內文中需要完整的訂閱資源。 確保更新所需的屬性。

如果訂閱的 autoRenewEnabled 設置為 true、具有 next term 說明或具有 next billing instructions,則這些所述屬性需要作為 PATCH 請求正文的一部分。 如果未提供這些屬性,則 autoRenewEnabled 會無意中設置為 false,或者下一個期限/計費說明將被刪除。 這僅適用於有效負載中的資訊最少的情況。 如果之前進行了 Get 調用,並且所述回應被修改並傳遞給 API,則必填欄位將填充到請求中。

備註

PartnerID 僅對分銷商定義其客戶訂閱的正式合作夥伴有意義。 直接帳單合作夥伴會看到 PartnerID 為空。 在歐盟/歐洲自由貿易聯盟市場營運的經銷商,可能會在同一訂閱中分配多個經銷商。 訂閱中所有合作夥伴 ID 必須符合驗證要求,才能更新訂閱。 更多關於歐盟/歐洲自由貿易聯盟(EFTA)的經銷商,請參閱 訂閱管理文件。

請求示例 #1a

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<id-for-subscription> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

{
    "Id": "83ef9d05-4169-4ef9-9657-0e86b1eab1de",
    "FriendlyName": "nickname",
    "Quantity": 2,
    "UnitType": "none",
    "ParentSubscriptionId": null,
    "CreationDate": "2015-11-25T06:41:12Z",
    "EffectiveStartDate": "2015-11-24T08:00:00Z",
    "CommitmentEndDate": "2016-12-12T08:00:00Z",
    "Status": "active",
    "AutoRenewEnabled": false,
    "BillingType": "none",
    "partnerId": "5357564",
    "additionalPartnerIds": ["517285","5357563"],
    "ContractType": "subscription",
    "OrderId": "6183db3d-6318-4e52-877e-25806e4971be",
    "Attributes": {
        "Etag": "<etag>",
        "ObjectType": "Subscription"
    }
}

請求範例 #1b:用於更新友好名稱的新商業訂閱

授權型服務的新商務體驗包含許多新功能,可供所有雲端解決方案提供者合作夥伴使用。 有關詳細資訊,請參閱 新商業體驗概述。

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscription-id> HTTP/1.1 
Authorization: Bearer <token> 
Accept: application/json 
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831 
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd 
Content-Type: application/json 
Content-Length: 1029 
Expect: 100-continue 
Connection: Keep-Alive 
 
{ 
    "id": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e", 
    "offerId": "CFQ7TTC0LH18:0001:CFQ7TTC0K971", 
    "offerName": "Microsoft 365 Business Basic", 
    "friendlyName": "nickname", //originally Microsoft 365 Business Basic 
    "productType": { 
        "id": "OnlineServicesNCE", 
        "displayName": "OnlineServicesNCE" 
    }, 
    "quantity": 1, 
    "unitType": "Licenses", 
    "hasPurchasableAddons": false, 
    "creationDate": "2021-01-14T16:57:15.0966728Z", 
    "effectiveStartDate": "2021-01-14T16:57:14.498252Z", 
    "commitmentEndDate": "2022-01-13T00:00:00Z", 
    "status": "active",  
    "autoRenewEnabled": true, //must be included if set to true; see note in Request Body section 
    "isTrial": false, 
    "billingType": "license", 
    "billingCycle": "monthly", 
    "termDuration": "P1Y", 
    "renewalTermDuration": "", 
    "refundOptions": [ 
        { 
            "type": "Full", 
            "expiresAt": "2021-01-15T00:00:00Z" 
        } 
    ], 
    "isMicrosoftProduct": true, 
    "partnerId": "5357564",
    "additionalPartnerIds": ["517285","5357563"],
    "attentionNeeded": false, 
    "actionTaken": false, 
    "contractType": "subscription", 
    "links": { 
        "product": { 
            "uri": "/products/CFQ7TTC0LH18?country=US", 
            "method": "GET", 
            "headers": [] 
        }, 
        "sku": { 
            "uri": "/products/CFQ7TTC0LH18/skus/0001?country=US", 
            "method": "GET", 
            "headers": [] 
        }, 
        "availability": { 
            "uri": "/products/CFQ7TTC0LH18/skus/0001/availabilities/CFQ7TTC0K971?country=US", 
            "method": "GET", 
            "headers": [] 
        }, 
        "self": { 
            "uri": "/customers/d8202a51-69f9-4228-b900-d0e081af17d7/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e", 
            "method": "GET", 
            "headers": [] 
        } 
    }, 
    "publisherName": "Microsoft Corporation", 
    "orderId": "34b37d7340cc", 
    "attributes": { 
        "objectType": "Subscription" 
    } 
} 

REST 響應

如果成功,此方法會傳回 HTTP 狀態 200 狀態代碼,並在回應本文中更新 訂用帳戶資源 屬性。

回應成功和錯誤碼

每個回應都返回一個 HTTP 狀態代碼,該代碼指示成功或失敗以及其他調試資訊。 使用網路追蹤工具讀取狀態代碼、錯誤類型和其他參數。 如需完整清單,請參閱錯誤代碼。

當修補作業花費的時間超過預期時間時,合作夥伴中心會傳送 HTTP 狀態 202 狀態代碼,以及指向擷取訂閱位置的標頭。 您可以定期查詢訂閱以監控訂閱狀態。

回應範例

回應示例 #1a

具有 HTTP 狀態 200 狀態代碼的成功的請求:

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscriptionID> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-Contract-Version: v1
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

{
    "Id": "83ef9d05-4169-4ef9-9657-0e86b1eab1de",
    "FriendlyName": "nickname",
    "Quantity": 1,
    "UnitType": "none",
    "ParentSubscriptionId": null,
    "CreationDate": "2015-11-25T06:41:12Z",
    "EffectiveStartDate": "2015-11-24T08:00:00Z",
    "CommitmentEndDate": "2016-12-12T08:00:00Z",
    "Status": "active",
    "AutoRenewEnabled": true,
    "BillingType": "none",
    "partnerId": "5357564",
    "additionalPartnerIds": ["517285","5357563"],
    "ContractType": "subscription",
    "Links": {
        "Offer": {
            "Uri": "/v1/offers/0CCA44D6-68E9-4762-94EE-31ECE98783B9",
            "Method": "GET",
            "Headers": []
        },
        "Entitlement": {
            "Uri": "/entitlements?key=<key>",
            "Method": "GET",
            "Headers": []
        },
        "Self": {
            "Uri": "/subscriptions?key=<key>",
            "Method": "GET",
            "Headers": []
        }
    },
    "OrderId": "6183db3d-6318-4e52-877e-25806e4971be",
    "Attributes": {
        "Etag": "<etag>",
        "ObjectType": "Subscription"
    }
}

回應示例 #1b:用於更新友好名稱的新商業訂閱

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscription-id> HTTP/1.1 
Authorization: Bearer <token> 
Accept: application/json 
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831 
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd 
Content-Type: application/json 
Content-Length: 1029 
Expect: 100-continue 
Connection: Keep-Alive 
 
{ 
    "id": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e", 
    "offerId": "CFQ7TTC0LH18:0001:CFQ7TTC0K971", 
    "offerName": "Microsoft 365 Business Basic", 
    "friendlyName": "nickname",  
    "productType": { 
        "id": "OnlineServicesNCE", 
        "displayName": "OnlineServicesNCE" 
    }, 
    "quantity": 1, 
    "unitType": "Licenses", 
    "hasPurchasableAddons": false, 
    "creationDate": "2021-01-14T16:57:15.0966728Z", 
    "effectiveStartDate": "2021-01-14T16:57:14.498252Z", 
    "commitmentEndDate": "2022-01-13T00:00:00Z", 
    "status": "active",  
    "autoRenewEnabled": true, 
    "isTrial": false, 
    "billingType": "license", 
    "billingCycle": "monthly", 
    "termDuration": "P1Y", 
    "renewalTermDuration": "", 
    "refundOptions": [ 
        { 
            "type": "Full", 
            "expiresAt": "2021-01-15T00:00:00Z" 
        } 
    ], 
    "isMicrosoftProduct": true, 
    "partnerId": "5357564",
    "additionalPartnerIds": ["517285","5357563"],
    "attentionNeeded": false, 
    "actionTaken": false, 
    "contractType": "subscription", 
    "links": { 
        "product": { 
            "uri": "/products/CFQ7TTC0LH18?country=US", 
            "method": "GET", 
            "headers": [] 
        }, 
        "sku": { 
            "uri": "/products/CFQ7TTC0LH18/skus/0001?country=US", 
            "method": "GET", 
            "headers": [] 
        }, 
        "availability": { 
            "uri": "/products/CFQ7TTC0LH18/skus/0001/availabilities/CFQ7TTC0K971?country=US", 
            "method": "GET", 
            "headers": [] 
        }, 
        "self": { 
            "uri": "/customers/d8202a51-69f9-4228-b900-d0e081af17d7/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e", 
            "method": "GET", 
            "headers": [] 
        } 
    }, 
    "publisherName": "Microsoft Corporation", 
    "orderId": "34b37d7340cc", 
    "attributes": { 
        "objectType": "Subscription" 
    } 
}

回應範例 #2

HTTP 狀態碼 202:請求成功。

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscriptionID> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 01880c1b-1966-40f0-d470-501a66d9948b
MS-CorrelationId: bbbb1111-cc22-3333-44dd-555555eeeeee
Content-Type: application/json
Content-Length: 1432
Connection: Keep-Alive
Location: /customers/<customer-tenant-id>/subscriptions/<subscriptionID>