获取客户的订阅
适用于:合作伙伴中心|由世纪互联运营的合作伙伴中心|适用于Microsoft Cloud for US Government的合作伙伴中心
如何获取客户的订阅集合。
必备条件
合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和 App+用户凭据进行身份验证。
客户 ID (
customer-tenant-id)。 如果不知道客户的 ID,则可以在合作伙伴中心仪表板中查找它。 从“合作伙伴中心”菜单中选择“CSP” ,然后选择“客户” 。 从客户列表中选择客户,然后选择“帐户” 。 在客户的“帐户”页上的“客户帐户信息” 部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。
C#
若要获取客户所有订阅的列表,请先使用具有客户标识符的 IAggregatePartner.Customers.ById 方法来标识客户。 然后使用 Subscriptions 属性检索订阅集合操作的接口。 最后,调用 Get 或 GetAsync 方法以检索客户的订阅集合。
// IAggregatePartner partnerOperations;
// string customerId;
var customerSubscriptions = partnerOperations.Customers.ById(customerId).Subscriptions.Get();
示例: 控制台测试应用。 项目:合作伙伴中心 SDK 示例 类:GetSubscriptions.cs
REST 请求
请求语法
| 方法 | 请求 URI |
|---|---|
| GET | {baseURL}/v1/customers/{customer-tenant-id}/subscriptions HTTP/1.1 |
URI 参数
下表列出了获取所有订阅所需的查询参数。
| 名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
| customer-tenant-id | 字符串 | 是 | 一个 GUID 格式的字符串,用于标识客户。 |
请求标头
有关详细信息,请参阅合作伙伴中心 REST 标头。
请求正文
无。
请求示例
GET https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: b2d13828-2ca5-41d4-94fb-9946214f4244
MS-CorrelationId: c49004b1-224f-4d86-a607-6c8bcc52cfdd
Connection: Keep-Alive
REST 响应
如果成功,此方法在响应正文中返回 订阅 资源的集合。
响应的成功和错误代码
每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 如需完整列表,请参阅合作伙伴中心 REST 错误代码。
响应示例
HTTP/1.1 200 OK
Content-Length: 73754
Content-Type: application/json
MS-CorrelationId: c49004b1-224f-4d86-a607-6c8bcc52cfdd
MS-RequestId: b2d13828-2ca5-41d4-94fb-9946214f4244
Date: Wed, 25 Nov 2015 05:43:06 GMT
{
"totalCount": 37,
"items": [{
"id": "83ef9d05-4169-4ef9-9657-0e86b1eab1de",
"entitlementId": "a356ac8c-e310-44f4-bf85-C7f29044af99",
"friendlyName": "nickname",
"quantity": 1,
"unitType": "none",
"creationDate": "2015-11-25T06: 41: 12Z",
"effectiveStartDate": "2015-11-24T08: 00: 00Z",
"commitmentEndDate": "2016-12-12T08: 00: 00Z",
"status": "active",
"autoRenewEnabled": false,
"billingType": "none",
"contractType": "subscription",
"links": {
"offer": {
"uri": "/v1/offers/0CCA44D6-68E9-4762-94EE-31ECE98783B9",
"method": "GET",
"headers": []
},
"self": {
"uri": "/subscriptions?key=<key>",
"method": "GET",
"headers": []
}
},
"orderId": "6183db3d-6318-4e52-877e-25806e4971be",
"attributes": {
"etag": "<etag>",
"objectType": "Subscription"
}
}],
"attributes": {
"objectType": "Collection"
}
}
{
"totalCount": 1,
"items": [
{
"id": "924671ba-eab9-45d7-95ed-dbd9477f182b",
"offerId": "DG7GMGF0FKZV:0003:DG7GMGF0DQLM",
"offerName": "SQL Server Enterprise - 2 Core License Pack - 3 year",
"friendlyName": "SQL Server Enterprise - 2 Core License Pack - 3 year",
"productType": {
"id": "Software",
"displayName": "Software"
},
"quantity": 1,
"unitType": "Licenses",
"hasPurchasableAddons": false,
"creationDate": "2021-10-15T21:28:19.3058617Z",
"effectiveStartDate": "2021-10-15T21:28:18.4786844Z",
"commitmentEndDate": "2024-10-14T00:00:00Z",
"cancellationAllowedUntilDate": "2021-11-14T23:59:00Z",
"status": "active",
"autoRenewEnabled": true,
"isTrial": false,
"billingType": "license",
"billingCycle": "triennial",
"termDuration": "P3Y",
"renewalTermDuration": "",
"isMicrosoftProduct": true,
"partnerId": "",
"attentionNeeded": false,
"actionTaken": false,
"contractType": "subscription",
"links": {
"product": {
"uri": "/products/DG7GMGF0FKZV?country=US",
"method": "GET",
"headers": []
},
"sku": {
"uri": "/products/DG7GMGF0FKZV/skus/0003?country=US",
"method": "GET",
"headers": []
},
"availability": {
"uri": "/products/DG7GMGF0FKZV/skus/0003/availabilities/DG7GMGF0DQLM?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/customers/954ca09a-1132-4088-bb58-30438dea2756/subscriptions/924671ba-eab9-45d7-95ed-dbd9477f182b",
"method": "GET",
"headers": []
}
},
"publisherName": "Microsoft",
"orderId": "12345678901",
"attributes": {
"objectType": "Subscription"
}
}
],
"links": {
"self": {
"uri": "/customers/954ca09a-1132-4088-bb58-30438dea2756/subscriptions",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "Collection"
}
}