Api'leri kullanarak katalog öğelerinin İş Ortağı Merkezi denetleme

Belirli bir katalog öğeleri kümesi için envanteri denetleme.

Önkoşullar

  • kimlik doğrulamasında açıklandığı gibi İş Ortağı Merkezi bilgileri. Bu senaryo hem tek başına Uygulama hem de Uygulama+Kullanıcı kimlik bilgileriyle kimlik doğrulamasını destekler.

  • Bir veya daha fazla ürün kimlikleri. İsteğe bağlı olarak, SKU kimlikleri de belirtilebilir.

  • Sağlanan ürün/SKU kimlikleri tarafından başvurulan SKU'ların envanterini doğrulamak için gereken ek bağlam. Bu gereksinimler ürün/SKU türüne göre değişiklik gösterebilir ve SKU'nunInventoryVariables özelliğinden belirlenebilir.

C#

Envanteri kontrol etmek için, denetlenen her öğe için bir InventoryItem nesnesi kullanarak bir InventoryCheckRequest nesnesi derleme. Ardından bir IAggregatePartner.Extensions erişimcisi kullanın, kapsamı Product olarak sildiniz ve ByCountry() yöntemini kullanarak ülkeyi seçin. Son olarak InventoryCheckRequest nesneniz ile CheckInventory() yöntemini çağırabilirsiniz.

IAggregatePartner partnerOperations;
string customerId;
string subscriptionId;
string countryCode;
string productId;

// Build the inventory check request details object.
var inventoryCheckRequest = new InventoryCheckRequest()
{
    TargetItems = new InventoryItem[]{ new InventoryItem { ProductId = productId } },
    InventoryContext = new Dictionary<string, string>()
    {
      { "customerId", customerId },
      { "azureSubscriptionId", subscriptionId }
      { "armRegionName", armRegionName }
    }
};

// Get the inventory results.
var inventoryResults = partnerOperations.Extensions.Product.ByCountry(countryCode).CheckInventory(inventoryCheckRequest);

REST isteği

İstek söz dizimi

Yöntem İstek URI'si
YAYINLA {baseURL}/v1/extensions/product/checkInventory?country={country-code} HTTP/1.1

URI parametresi

Envanteri kontrol etmek için aşağıdaki sorgu parametresini kullanın.

Ad Tür Gerekli Açıklama
ülke kodu string Yes Ülke/bölge kimliği.

İstek üst bilgileri

Daha fazla bilgi için bkz. İş Ortağı Merkezi REST üst bilgileri.

İstek gövdesi

Bir veya daha fazla InventoryItem kaynağı içeren inventoryCheckRequest kaynağından oluşan envanter isteği ayrıntıları.

İstek örneği

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: 4acb26a1-3536-4081-bc7d-092869a4961a
X-Locale: en-US
MS-PartnerCenter-Client: Partner Center .NET SDK
Content-Type: application/json

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

REST yanıtı

Başarılı olursa yanıt gövdesi, varsa kısıtlama ayrıntılarıyla doldurulmuş bir InventoryItem nesneleri koleksiyonu içerir.

Not

InventoryItem girişi katalogda buluna bir öğeyi temsil ediyorsa, çıkış koleksiyonuna dahil olmaz.

Yanıt başarı ve hata kodları

Her yanıt, başarılı veya başarısız olduğunu gösteren bir HTTP durum kodu ve ek hata ayıklama bilgileriyle birlikte gelir. Bu kodu, hata türünü ve ek parametreleri okumak için bir ağ izleme aracı kullanın. Tam liste için bkz. İş Ortağı Merkezi kodları.

Yanıt örneği

HTTP/1.1 200 OK
Content-Length: 1021
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 4acb26a1-3536-4081-bc7d-092869a4961a
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": []
    }
]