取得客戶的訂閱
適用於:合作夥伴中心 |由 21Vianet 營運的合作夥伴中心 |美國政府Microsoft雲端合作夥伴中心
如何取得客戶的訂閱集合。
先決條件
合作夥伴中心驗證中所述的認證。 此案例支援使用獨立應用程式和 App+使用者認證進行驗證。
客戶標識碼 (
customer-tenant-id
)。 如果您不知道客戶的標識碼,您可以在 合作夥伴中心 中選取 客戶 工作區,然後從客戶清單中選取該客戶,再選擇 帳戶進行查閱。 在客戶的 [帳戶] 頁面上,於 [客戶帳戶資訊] 區段中尋找 Microsoft 帳戶 ID。 Microsoft識別碼與客戶標識碼 (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 |
---|---|
取得 | {baseURL}/v1/customers/{customer-tenant-id}/subscriptions HTTP/1.1 |
URI 參數
下表列出取得所有訂用帳戶所需的查詢參數。
名字 | 類型 | 必填 | 描述 |
---|---|---|---|
客戶租戶識別碼 | 字串 | 是的 | 識別客戶的 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: aaaa0000-bb11-2222-33cc-444444dddddd
Connection: Keep-Alive
REST 回應
如果成功,這個方法會傳回回應本文中 訂用帳戶 資源的集合。
回應成功和錯誤碼
每個回應都有一個 HTTP 狀態代碼,指出成功或失敗和其他偵錯資訊。 使用網路追蹤工具來讀取此程式代碼、錯誤類型和其他參數。 如需完整清單,請參閱 合作夥伴中心 REST 錯誤碼。
回應範例
舊版在線服務訂用帳戶的回應範例
HTTP/1.1 200 OK
Content-Length: 73754
Content-Type: application/json
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: b2d13828-2ca5-41d4-94fb-9946214f4244
Date: Wed, 25 Nov 2015 05:43:06 GMT
{
"totalCount": 1,
"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": 2,
"items": [
{
"id": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"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/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"method": "GET",
"headers": []
}
},
"publisherName": "Microsoft Corporation",
"orderId": "f9a896ba4686",
"attributes": {
"objectType": "Subscription"
}
},
{
"id": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"offerId": "DG7GMGF0GJC2:0003:DG7GMGF0CFC5",
"offerName": "Azure SQL Edge - 1 year",
"friendlyName": "Azure SQL Edge",
"productType": {
"id": "Software",
"displayName": "Software"
},
"quantity": 1,
"unitType": "Licenses",
"hasPurchasableAddons": false,
"creationDate": "2023-11-28T22:21:15.015299Z",
"effectiveStartDate": "2023-11-28T22:21:12.5336906Z",
"commitmentEndDate": "2024-11-27T00:00:00Z",
"commitmentEndDateTime": "2024-11-27T23:59:59Z",
"cancellationAllowedUntilDate": "2023-12-05T22:21:37.7730547Z",
"billingCycleEndDate": "2024-11-27T00:00:00Z",
"billingCycleEndDateTime": "2024-11-27T23:59:59Z",
"status": "active",
"autoRenewEnabled": true,
"isTrial": false,
"billingType": "license",
"billingCycle": "annual",
"termDuration": "P1Y",
"renewalTermDuration": "",
"isMicrosoftProduct": true,
"partnerId": "",
"attentionNeeded": false,
"actionTaken": false,
"contractType": "subscription",
"links": {
"product": {
"uri": "/products/DG7GMGF0GJC2?country=US",
"method": "GET",
"headers": []
},
"sku": {
"uri": "/products/DG7GMGF0GJC2/skus/0003?country=US",
"method": "GET",
"headers": []
},
"availability": {
"uri": "/products/DG7GMGF0GJC2/skus/0003/availabilities/DG7GMGF0CFC5?country=US",
"method": "GET",
"headers": []
},
"self": {
"uri": "/customers/bfb6b398-c7f5-40f0-aa75-a1f1adf81374/subscriptions/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"method": "GET",
"headers": []
}
},
"publisherName": "Microsoft",
"orderId": "be34ac49aefb",
"attributes": {
"objectType": "Subscription"
}
}
]
}