顧客サブスクリプションのライセンス数を変更する

適用対象: パートナー センター | 21Vianet が運営するパートナー センター | Microsoft Cloud for US Government のパートナー センター

サブスクリプションを更新して、ライセンスの数量を増減します。

前提条件

  • パートナー センターの認証に関するページで説明している資格情報。 このシナリオでは、スタンドアロン アプリとアプリ + ユーザーの両方の資格情報を使った認証がサポートされています。

  • 顧客 ID です (customer-tenant-id)。 顧客の ID がわからない場合は、パートナー センター[顧客] ワークスペースを選び、顧客一覧から顧客を選び、[アカウント] を選んで調べることができます。 顧客の [アカウント] ページの [顧客のアカウント情報] セクションで Microsoft ID を探します。 Microsoft ID は、顧客 ID (customer-tenant-id) と同じです。

  • サブスクリプション ID。

C#

顧客のサブスクリプションの数量を変更するには、まずサブスクリプションを取得サブスクリプションの Quantity プロパティを変更します。 変更が行われたら、 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,
selectedSubscription.Quantity++;

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

サンプル: Console テスト アプリProject: PartnerSDK.FeatureSample Class: UpdateSubscription.cs

REST 要求

要求の構文

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

URI パラメーター

次の表に、サブスクリプションの数量を変更するために必要なクエリ パラメーターを示します。

名前 タイプ Required 説明
customer-tenant-id guid 顧客に対応する GUID。
subscription-id guid サブスクリプションに対応する GUID。

要求ヘッダー

詳細については、「パートナー センター REST ヘッダー」を参照してください。

要求本文

要求本文には完全な Subscription リソースが必要です。 Quantity プロパティが更新されていることを確認します。

要求の例

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"
    }
}

数量を減らすための新しいコマース サブスクリプションの要求例

Note

ライセンスベースのサービスの新しいコマース エクスペリエンスには、多くの新機能が含まれており、すべてのクラウド ソリューション プロバイダー (CSP) で利用できます。 詳細については、新しいコマース エクスペリエンスの概要を参照してください。

ライセンス数は、法律で別途要求されている場合を除き、サブスクリプションの購入または更新から 7 日以内にのみ減らすことができます。 同様に、中間で追加されたライセンスも、7 日以内にのみ削減できます。

サブスクリプションで減額が許可されているかどうかを確認するには、ID によるサブスクリプションの取得 - パートナー アプリ開発者 API 要求の refundableQuantity フィールドを参照してください。

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": "Microsoft 365 Business Basic", 
    "productType": { 
        "id": "OnlineServicesNCE", 
        "displayName": "OnlineServicesNCE" 
    }, 
    "quantity": 1, // original value = 10 
    "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", 
    "refundableQuantity": { 
        "totalQuantity": 10, 
        "details": [ 
            { 
                "quantity": 10, 
                "allowedUntilDateTime": "2021-01-24T20:39:17.182697Z" 
            } 
        ] 
    }, 
    "orderId": "34b37d7340cc", 
    "attributes": { 
        "objectType": "Subscription" 
    } 
} 

REST 応答

成功した場合、このメソッドは HTTP 状態 200 状態コードと更新された サブスクリプション リソース プロパティを応答本文で返します。

応答の成功とエラーのコード

各応答は、成功または失敗と追加のデバッグ情報を示す HTTP 状態コードを返します。 ネットワーク トレース ツールを使用して、状態コード、エラーの種類、およびその他のパラメーターを読み取ります。 完全な一覧については、エラー コードに関するページを参照してください。

修正プログラムの操作に予想以上の時間がかかる場合、パートナー センターは、 HTTP 状態 202 状態コードと、サブスクリプションを取得する場所を指す場所ヘッダーを送信します。 サブスクリプションに定期的にクエリを実行して、状態と数量の変化を監視できます。

応答例

応答の例 #1

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": 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",
    "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"
    }
}

応答の例 #2

HTTP 状態 202 の成功した要求状態コード:

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": "Microsoft 365 Business Basic", 
    "productType": { 
        "id": "OnlineServicesNCE", 
        "displayName": "OnlineServicesNCE" 
    }, 
    "quantity": 1, // original value = 10 
    "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", 
   "refundableQuantity": { 
        "totalQuantity": 1, 
        "details": [ 
            { 
                "quantity": 1, 
                "allowedUntilDateTime": "2021-01-24T20:39:17.182697Z" 
            } 
        ] 
    }, 
    "orderId": "34b37d7340cc", 
    "attributes": { 
        "objectType": "Subscription" 
    } 
} 

新しいコマース ライセンスの削減に対する応答の例

Note

ライセンスベースのサービスの新しいコマース エクスペリエンスには、多くの新機能が含まれており、すべてのクラウド ソリューション プロバイダー (CSP) で利用できます。 詳細については、新しいコマース エクスペリエンスの概要を参照してください。

7 日間のキャンセル期間外に新しいコマース サブスクリプションのライセンス数を減らそうとしたときのサンプル API 応答。

{
    "code": 800090,
    "description": "Subscription quantity cannot be decreased.",
    "data": [],
    "source": "PartnerFD"
}