按市场获取产品/服务类别列表

适用于:合作伙伴中心 | 由世纪互联运营的合作伙伴中心 | Microsoft Cloud for US Government 合作伙伴中心

本文介绍如何获取包含给定国家/地区和区域设置中所有产品/服务类别的集合。

必备条件

C#

获取给定国家/地区和区域设置中的产品/服务类别列表:

  1. 使用 IAggregatePartner.Operations 集合在给定上下文中调用 With () 方法。

  2. 检查生成的 对象的 OfferCategories 属性。

// IAggregatePartner partnerOperations;

ResourceCollection<OfferCategory> offerCategoryResults = partnerOperations.With(RequestContextFactory.Instance.Create()).OfferCategories.ByCountry("US").Get();

有关示例,请参阅以下内容:

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/offercategories?country={country-id} HTTP/1.1

URI 参数

下表列出了获取产品/服务类别所需的查询参数。

名称 类型 必须 说明
country-id string Y 国家/地区 ID。

请求标头

需要格式化为字符串 的区域设置 ID

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

请求正文

无。

请求示例

GET https://api.partnercenter.microsoft.com/v1/offercategories?country=<country-id> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 4fb54bd5-a4c3-4fac-955f-9b6e3436d606
MS-CorrelationId: 47882653-eaed-4a2e-a552-1070a3fa1089
X-Locale: <locale-id>
Connection: Keep-Alive

REST 响应

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

响应的成功和错误代码

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

响应示例

HTTP/1.1 200 OK
Content-Length: 1184
Content-Type: application/json
MS-CorrelationId: 47882653-eaed-4a2e-a552-1070a3fa1089
MS-RequestId: 4fb54bd5-a4c3-4fac-955f-9b6e3436d606
Date: Thu, 26 Nov 2015 00:07:10 GMT

{
    "totalCount": 4,
    "items": [{
        "id": "Enterprise_Key",
        "name": "Enterprise",
        "rank": 20,
        "locale": "en-us",
        "country": "US",
        "attributes": {
            "objectType": "OfferCategory"
        }
    },
    {
        "id": "SmallBusiness_Key",
        "name": "SmallBusiness",
        "rank": 30,
        "locale": "en-us",
        "country": "US",
        "attributes": {
            "objectType": "OfferCategory"
        }
    },
    {
        "id": "Government_Key",
        "name": "Government",
        "rank": 40,
        "locale": "en-us",
        "country": "US",
        "attributes": {
            "objectType": "OfferCategory"
        }
    },
    {
        "id": "Internal_Key",
        "name": "Internal",
        "rank": 100,
        "locale": "en-us",
        "country": "US",
        "attributes": {
            "objectType": "OfferCategory"
        }
    }],
    "attributes": {
        "objectType": "Collection"
    }
}