按 ID 更新订阅
适用于:合作伙伴中心 | 由世纪互联运营的合作伙伴中心 | Microsoft Cloud for US Government 合作伙伴中心
在合作伙伴中心,首先 选择客户来执行此操作。 然后,选择要更新的订阅。 若要完成,请更改所需的值,然后选择“ 提交”。
先决条件
合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和 App+User 凭据进行身份验证。
客户 ID (
customer-tenant-id
)。 如果不知道客户的 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 |
---|---|
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: 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": 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: 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": "",
"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": 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: 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": "",
"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>