使用合作伙伴中心 API 检查目录产品的库存

如何检查一组特定目录项的清单。

重要

此 API 将于 2026 年 9 月 25 日停用。 合作伙伴应迁移到新的 按资源类型检查库存 API,该 API 提供了更好的按资源类型筛选功能。

先决条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和 App+User 凭据进行身份验证。

  • 一个或多个商品 ID。 (可选)还可以指定 SKU ID。

  • 验证所提供的产品/SKU ID 引用的 SKU 库存时,是否需要任何额外上下文。 这些要求可能因产品/SKU 类型而异,并且可以从 SKU 的InventoryVariables 属性确定。

REST 请求

请求语法

方法 请求 URI
POST {baseURL}/v1/extensions/product/checkInventory?country={country-code} HTTP/1.1

URI 参数

使用以下查询参数检查清单。

名称 类型 必选 DESCRIPTION
国家/地区代码 字符串 是的 国家/地区 ID。

请求标头

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

请求主体

清单请求详细信息,由包含一个或多个 InventoryItem 资源的 InventoryCheckRequest 资源组成。

确保请求正文中指定的 Azure 订阅已注册,并已启用购买 Azure RI 的功能。 有关注册过程的详细信息,请参阅 注册订阅 。

请求示例

POST https://api.partnercenter.microsoft.com/v1/extensions/product/checkinventory?country=US HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: d1b1981a-e088-4610-870a-eebec96d6bcd
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Content-Type: application/json

{"TargetItems":[{"ProductId":"DZH318Z0BQ3P"}],"InventoryContext":{"customerId":"d6bf25b7-e0a8-4f2d-a31b-97b55cfc774d","azureSubscriptionId":"3A231FBE-37FE-4410-93FD-730D3D5D4C75","armRegionName":"Europe"}}

REST 响应

如果成功,响应正文将包含一组 InventoryItem 对象,其中填充了限制详细信息(如果有)。

注释

如果输入 InventoryItem 表示在目录中找不到的项目,则不会将其包含在输出集合中。

成功响应和错误代码

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

响应示例

HTTP/1.1 200 OK
Content-Length: 1021
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: d1b1981a-e088-4610-870a-eebec96d6bcd
X-Locale: en-US
[
    {
        "productId": "DZH318Z0BQ3P",
        "skuId": "0039",
        "isRestricted": true,
        "restrictions": [
            {
                "reasonCode": "NotAvailableForSubscription",
                "description": "Restriction identified of type 'Location' with values 'japanwest'.",
                "properties": {
                    "type": "Location",
                    "values": "japanwest"
                }
            }
        ]
    },
    {
        "productId": "DZH318Z0BQ3P",
        "skuId": "0038",
        "isRestricted": true,
        "restrictions": [
            {
                "reasonCode": "NotAvailableForSubscription",
                "description": "Restriction identified of type 'Location' with values 'japanwest'.",
                "properties": {
                    "type": "Location",
                    "values": "japanwest"
                }
            }
        ]
    },
    {
        "productId": "DZH318Z0BQ3P",
        "skuId": "000S",
        "isRestricted": false,
        "restrictions": []
    },
    {
        "productId": "DZH318Z0BQ3P",
        "skuId": "0011",
        "isRestricted": false,
        "restrictions": []
    }
]