次の方法で共有


ID によるサブスクリプションの更新

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

ID で サブスクリプション を更新します。

パートナー センターで、最初に 顧客を選択して、この操作を実行します。 次に、更新する問題のサブスクリプションを選択します。 終了するには、必要な値を変更し、[ 送信] を選択します。

[前提条件]

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

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

  • サブスクリプション 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 パラメーター

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

名前 タイプ 必須 説明
顧客テナントID GUIDの Y 顧客に対応する GUID。
サブスクリプション ID GUIDの Y サブスクリプションに対応する GUID。

要求ヘッダー

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

リクエストの本文

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

サブスクリプションの autoRenewEnabled が true に設定されている場合、次の期間の指示がある場合、または次の請求指示がある場合、これらの属性は PATCH 要求の本文の一部として必要です。 これらの属性が指定されていない場合、autoRenewEnabled が誤って false に設定されるか、次の期間/請求手順が削除されます。 これは、ペイロードに最小限の情報が含まれている場合にのみ適用されます。 Get 呼び出しが以前に行われ、その応答が変更されて API に渡された場合、必要なフィールドが要求に入力されます。

PartnerID は、顧客のサブスクリプションのレコードパートナーを定義するディストリビューターにのみ関連します。 直接請求パートナーは、partnerID を null と見なします。 EU/EFTA 市場で運用されているディストリビューターには、1 つのサブスクリプションに複数のリセラーが割り当てられている場合があります。 サブスクリプションのすべてのパートナー ID は、サブスクリプションを更新する前に検証要件を満たす必要があります。 EU/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: フレンドリ名を更新するための新しいコマース サブスクリプション

ライセンスベースのサービスの新しいコマース エクスペリエンスには、多くの新機能が含まれており、すべてのクラウド ソリューション プロバイダー パートナー (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: 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>