共用方式為


依標識碼更新訂用帳戶

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

依標識碼更新訂用帳戶

在合作夥伴中心,先 選取客戶來執行這項作業。 然後,選取您想要更新的訂用帳戶。 若要完成,請變更所需的值,然後選取 [ 提交]。

必要條件

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);

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

REST 要求

要求語法

方法 要求 URI
PATCH {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id} HTTP/1.1

URI 參數

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

名稱 類型​​ 必要 描述
customer-tenant-id guid Y 對應至客戶的 GUID。
subscription-id guid Y 對應至訂用帳戶的 GUID。

要求標頭

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

要求本文

要求本文中需要完整的 用帳戶資源。 請確定已更新所需的屬性。

如果訂用帳戶的 autoRenewEnabled 設定為 true、具有下一個字詞指示,或有下一個計費指示,則這些表示屬性是 PATCH 要求的本文一部分。 如果未提供這些屬性,autoRenewEnabled 會不小心設定為 false,或刪除下一個字詞/帳單指示。 只有在承載中最小資訊時才適用。 如果在之前進行 Get 呼叫,且表示回應已修改並傳遞至 API,則會在要求中填入必要的欄位。

要求範例 #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: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
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": null,
    "ContractType": "subscription",
    "OrderId": "6183db3d-6318-4e52-877e-25806e4971be",
    "Attributes": {
        "Etag": "<etag>",
        "ObjectType": "Subscription"
    }
}

要求範例 #1b:更新易記名稱的新商務訂閱

授權型服務的新商務體驗包含許多新功能,且適用於所有 雲端解決方案提供者 合作夥伴(CSP)。 如需詳細資訊,請參閱 新的商務體驗概觀

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: ec8f62e5-1d92-47e9-8d5d-1924af105f2c 
Content-Type: application/json 
Content-Length: 1029 
Expect: 100-continue 
Connection: Keep-Alive 
 
{ 
    "id": "a4c1340d-6911-4758-bba3-0c4c6007d161", 
    "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": "", 
    "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/a4c1340d-6911-4758-bba3-0c4c6007d161", 
            "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: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
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": null,
    "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: ec8f62e5-1d92-47e9-8d5d-1924af105f2c 
Content-Type: application/json 
Content-Length: 1029 
Expect: 100-continue 
Connection: Keep-Alive 
 
{ 
    "id": "a4c1340d-6911-4758-bba3-0c4c6007d161", 
    "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": "", 
    "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/a4c1340d-6911-4758-bba3-0c4c6007d161", 
            "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: 2c5827c1-d5f9-4835-cc6d-f1918b782c79
Content-Type: application/json
Content-Length: 1432
Connection: Keep-Alive
Location: /customers/<customer-tenant-id>/subscriptions/<subscriptionID>