根据 ID 获取订阅
适用于:合作伙伴中心 | 由世纪互联运营的合作伙伴中心 | Microsoft Cloud for US Government 合作伙伴中心
获取与 客户 ID 和订阅 ID 匹配的订阅 资源。
先决条件
合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和 App+User 凭据进行身份验证。
客户 ID (
customer-tenant-id
)。 如果不知道客户的 ID,可以通过选择“客户”工作区,然后从客户列表中选择客户,然后选择“帐户”,在合作伙伴中心中查找该 ID。 在客户的“帐户”页上,在“客户帐户信息”部分查找Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id
) 相同。订阅 ID。
C#
若要按 ID 获取订阅,请首先通过调用具有客户 ID 的 IAggregatePartner.Customers.ById 方法来获取订阅操作的接口,并使用 Subscriptions.ById 方法标识订阅。 使用该接口通过调用 Get 来检索订阅详细信息。
// IAggregatePartner partnerOperations;
// string selectedCustomerId;
// string subscriptionID;
var subscriptionDetails = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(subscriptionID).Get();
示例: 控制台测试应用。 项目:合作伙伴中心 SDK 示例 类:GetSubscription.cs
REST 请求
请求语法
方法 | 请求 URI |
---|---|
GET | {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{id-for-subscription} HTTP/1.1 |
URI 参数
下表列出了获取订阅所需的查询参数。
名称 | 类型 | 必需 | 说明 |
---|---|---|---|
customer-tenant-id | guid | Y | 对应于客户的 GUID。 |
id-for-subscription | guid | Y | 对应于订阅的 GUID。 |
请求标头
有关详细信息,请参阅合作伙伴中心 REST 标头。
请求正文
无。
请求示例
GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 8f489776-a3f3-47cb-91c3-538e1f70f560
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com
REST 响应
如果成功,此方法在响应正文中返回 订阅 资源。
响应的成功和错误代码
每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 如需完整列表,请参阅合作伙伴中心 REST 错误代码。
Microsoft Azure 订阅的响应示例
HTTP/1.1 200 OK
Content-Length: 833
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 8f489776-a3f3-47cb-91c3-538e1f70f560
MS-CV: 7v11Wa//5EuGEo+A.0
MS-ServerId: 202010406
Date: Fri, 27 Jan 2017 21:51:40 GMT
{
"id": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"entitlementId": "42226ED6-070A-4E0F-B80C-4CDFB3E97AA7",
"offerId": "MS-AZR-0145P",
"offerName": "Microsoft Azure",
"friendlyName": "Microsoft Azure",
"quantity": 1,
"unitType": "Usage-based",
"creationDate": "2016-05-10T07:30:05.427Z",
"effectiveStartDate": "2016-05-10T00:00:00Z",
"commitmentEndDate": "9999-12-10T00:00:00Z",
"status": "active",
"autoRenewEnabled": false,
"billingType": "usage",
"contractType": "subscription",
"links": {
"offer": {
"uri": "/offers/MS-AZR-0145P?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"method": "GET",
"headers": []
}
},
"orderId": "B23FDEDD-D6BD-415A-8B71-3624C81C9644",
"attributes": {
"etag": "eyJpZCI6ImEzNTZhYzhjLWUzMTAtNDRmNC1iZjg1LWM3ZjI5MDQ0YWY5OSIsInZlcnNpb24iOjJ9",
"objectType": "Subscription"
}
}
加载项订阅的响应示例
加载项订阅的响应包括正文和链接中的父订阅 ID。
HTTP/1.1 200 OK
Content-Length: 1132
Content-Type: application/json; charset=utf-8
MS-CorrelationId: bbbb1111-cc22-3333-44dd-555555eeeeee
MS-RequestId: 22bfd0fb-d1e6-4a8f-aa1a-124b7c820d80
MS-CV: cmde2DtbuUWi8JLq.0
MS-ServerId: 201022015
Date: Fri, 27 Jan 2017 00:12:53 GMT
{
"id": "cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a",
"offerId": "2828BE95-46BA-4F91-B2FD-0BEF192ECF60",
"offerName": "Exchange Online Archiving for Exchange Online",
"friendlyName": "Some friendly name",
"quantity": 2,
"unitType": "Licenses",
"parentSubscriptionId": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"creationDate": "2017-01-25T23:01:08.693Z",
"effectiveStartDate": "2017-01-25T00:00:00Z",
"commitmentEndDate": "2018-02-10T00:00:00Z",
"commitmentEndDateTime": "2018-02-10T00:00:00Z",
"status": "active",
"autoRenewEnabled": true,
"billingType": "license",
"contractType": "subscription",
"links": {
"offer": {
"uri": "/offers/2828BE95-46BA-4F91-B2FD-0BEF192ECF60?country=US",
"method": "GET",
"headers": []
},
"parentSubscription": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"method": "GET",
"headers": []
},
"self": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a",
"method": "GET",
"headers": []
}
},
"orderId": "CF3B0E37-BE0B-4CDD-B584-D1A97D98A922",
"attributes": {
"etag": "eyJpZCI6Ijk2OGJhMWNmLWMxNDYtNGFkZi1hMzAwLTMwOGRjZjcxOGVlZSIsInZlcnNpb24iOjF9",
"objectType": "Subscription"
}
}
新商务订阅的响应示例
注意
基于许可证的服务的新商业体验涵盖许多新功能,可供所有云解决方案提供商 (CSP) 使用。 有关详细信息,请参阅新商业体验概述。
HTTP/1.1 200 OK
Content-Length: 1132
Content-Type: application/json; charset=utf-8
MS-CorrelationId: cccc2222-dd33-4444-55ee-666666ffffff
MS-RequestId: 54sfd0fb-d1e6-4a8f-aa1a-124b7c820d80
MS-CV: cmde2DtbuUWi8JLq.0
MS-ServerId: 201022015
Date: Fri, 17 Nov 2023 00:14:53 GMT
{
"id": "dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b",
"offerId": "CFQ7TTC0LFLZ:0002:CFQ7TTC0MKD5",
"offerName": "Microsoft 365 E5",
"friendlyName": "Microsoft 365 E5",
"productType": {
"id": "OnlineServicesNCE",
"displayName": "OnlineServicesNCE"
},
"quantity": 1,
"unitType": "Licenses",
"hasPurchasableAddons": false,
"consumptionType": "overage",
"creationDate": "2023-11-28T22:28:50.7842638Z",
"effectiveStartDate": "2023-11-28T00:00:00Z",
"commitmentEndDate": "2023-12-27T00:00:00Z",
"commitmentEndDateTime": "2023-12-27T23:59:59Z",
"cancellationAllowedUntilDate": "2023-12-05T22:29:25.9967858Z",
"billingCycleEndDate": "2023-12-27T00:00:00Z",
"billingCycleEndDateTime": "2023-12-27T23:59:59Z",
"status": "active",
"autoRenewEnabled": true,
"isTrial": false,
"billingType": "license",
"billingCycle": "monthly",
"termDuration": "P1M",
"renewalTermDuration": "",
"refundOptions": [
{
"type": "Full",
"expiresAt": "2023-11-29T22:29:25.9967858Z"
}
],
"isMicrosoftProduct": true,
"partnerId": "",
"attentionNeeded": false,
"actionTaken": false,
"contractType": "subscription",
"links": {
"product": {
"uri": "/products/CFQ7TTC0LFLZ?country=US",
"method": "GET",
"headers": []
},
"sku": {
"uri": "/products/CFQ7TTC0LFLZ/skus/0002?country=US",
"method": "GET",
"headers": []
},
"availability": {
"uri": "/products/CFQ7TTC0LFLZ/skus/0002/availabilities/CFQ7TTC0MKD5?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/customers/bfb6b398-c7f5-40f0-aa75-a1f1adf81374/subscriptions/dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b",
"method": "GET",
"headers": []
}
},
"publisherName": "Microsoft Corporation",
"orderId": "f9a896ba4686",
"attributes": {
"objectType": "Subscription"
}
}