按订单获取订阅列表

适用于:合作伙伴中心 | 由世纪互联运营的合作伙伴中心 | 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 属性,后跟 ByOrder() 方法。 最后,调用 Get()GetAsync()

// IAggregatePartner partnerOperations;
// var selectedCustomerId as string;
// string orderID;

ResourceCollection<Subscription> customerSubscriptions = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ByOrder(orderID).Get();

示例控制台测试应用项目:PartnerSDK.FeatureSample :SubscriptionsByOrder.cs

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/customers/{customer-tenant-id}/subscriptions?order_id={id-for-order} HTTP/1.1

URI 参数

下表列出了获取所有订阅所需的查询参数。

名称 类型​​ 必需 说明
customer-tenant-id guid Y 对应于客户的 GUID。
id-for-order guid Y 对应于订单的 GUID。

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求正文

无。

请求示例

GET https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/subscriptions?order_id={id-for-order} HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 16fee928-dc2c-412f-adbb-871f68babf16
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
Connection: Keep-Alive

REST 响应

如果成功,此方法在响应正文中返回订阅资源的集合

响应的成功和错误代码

每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅错误代码

响应示例

HTTP/1.1 200 OK
Content-Length: 73754
Content-Type: application/json
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 16fee928-dc2c-412f-adbb-871f68babf16
Date: Wed, 25 Nov 2015 05:50:45 GMT

{
    "totalCount": 1,
    "items": [{
        "id": "83ef9d05-4169-4ef9-9657-0e86b1eab1de",
        "entitlementId": "a356ac8c-e310-44f4-bf85-C7f29044af99",
        "friendlyName": "Myofferpurchase",
        "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": "{id-for-order}",
        "attributes": {
            "etag": "<etag>",
            "objectType": "Subscription"
        }
    }],
    "attributes": {
        "objectType": "Collection"
    }
}

新商务中的响应示例

GET https://api.partnercenter.microsoft.com/v1/customers/c501c3c4-d776-40ef-9ecf-9cefb59442c1//subscriptions?order_id=79d9f5e2f43a HTTP/1.1
Content-Length: 73754
Content-Type: application/json
MS-RequestId: 261a7eab-99ba-4fef-b3f1-476ebfddfa52
MS-CorrelationId: bbbb1111-cc22-3333-44dd-555555eeeeee
Date: Thurs, 6 June 2024 10:50:45 GMT

{
  "totalCount": 1,
  "items": [
    {
        "id": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
        "offerId": "CFQ7TTC0LH18:0001:CFQ7TTC0P0WS",
        "offerName": "Microsoft 365 Business Basic",
        "friendlyName": "Microsoft 365 Business Basic",
        "productType": {
            "id": "OnlineServicesNCE",
            "displayName": "OnlineServicesNCE"
        },
        "quantity": 2,
        "unitType": "Licenses",
        "hasPurchasableAddons": false,
        "creationDate": "2024-06-05T19:26:38.3667635Z",
        "effectiveStartDate": "2024-06-05T00:00:00Z",
        "commitmentEndDate": "2024-07-04T00:00:00Z",
        "commitmentEndDateTime": "2024-07-04T23:59:59Z",
        "cancellationAllowedUntilDate": "2024-06-12T19:27:03.440527Z",
        "billingCycleEndDate": "2024-07-04T00:00:00Z",
        "billingCycleEndDateTime": "2024-07-04T23:59:59Z",
        "status": "active",
        "autoRenewEnabled": true,
        "isTrial": false,
        "billingType": "license",
        "billingCycle": "monthly",
        "termDuration": "P1M",
        "renewalTermDuration": "",
        "isMicrosoftProduct": true,
        "partnerId": "4847383",
        "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/CFQ7TTC0P0WS?country=US",
                "method": "GET",
                "headers": []
            },
            "self": {
                "uri": "/customers/c501c3c4-d776-40ef-9ecf-9cefb59442c1/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
                "method": "GET",
                "headers": []
            }
        },
        "publisherName": "Microsoft Corporation",
        "refundableQuantity": {
            "totalQuantity": 1,
            "details": [
                {
                    "quantity": 1,
                    "allowedUntilDateTime": "2024-06-14T17:41:13.4675407Z"
                }
            ]
        },
        "orderId": "79d9f5e2f43a",
        "attributes": {
            "objectType": "Subscription"
        }
    }
  ],
  "attributes": { "objectType": "Collection" }
}