Faturalanmamış ticari tüketim satırı öğelerini alın
Bilgisiz ticari tüketim satırı öğesi ayrıntılarının bir koleksiyonunu elde edin.
Program aracılığıyla bilgi toplanmamış ticari tüketim satırı öğeleri (açık kullanım satırı öğeleri olarak da bilinir) koleksiyonu almak için aşağıdaki yöntemleri kullanabilirsiniz.
Not
Günlük olarak derecelendirilmiş kullanımın api'de görünmesi İş Ortağı Merkezi veya API üzerinden erişilebilir olması 24 saat sürer.
Ö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.
C#
Belirtilen faturanın satır öğelerini almak için:
Belirtilen faturaya yönelik fatura işlemlerine arabirim almak için ById yöntemini çağırma.
Fatura nesnesini almak için Get veya GetAsync yöntemini çağırma.
Invoice nesnesi, belirtilen faturayla ilgili tüm bilgileri içerir. Sağlayıcı, bilgisiz ayrıntı bilgisinin kaynağını tanımlar (örneğin, OneTime). InvoiceLineItemType türü belirtir (örneğin, UsageLineItem).
Aşağıdaki örnek kod, InvoiceLineItems koleksiyonunu işlemeye bir foreach döngüsü kullanır. Her InvoiceLineItemTypeiçin ayrı bir satır öğeleri koleksiyonu alınır.
InvoiceDetail örneğine karşılık gelen satır öğeleri koleksiyonunu almak için:
Örneğin BillingProvider veInvoiceLineItemType bilgilerini By yöntemine geçin.
İlişkili satır öğelerini almak için Get veya GetAsync yöntemini çağırma.
Aşağıdaki örnekte gösterildiği gibi koleksiyonu çapraz geçiş yapmak için bir numaralayıcı oluşturun.
// IAggregatePartner partnerOperations;
// string curencyCode;
// string period;
// int pageMaxSizeReconLineItems = 2000;
// all the operations executed on this partner operation instance will share the same correlation Id but will differ in request Id
IPartner scopedPartnerOperations = partnerOperations.With(RequestContextFactory.Instance.Create(Guid.NewGuid()));
var seekBasedResourceCollection = scopedPartnerOperations.Invoices.ById("unbilled").By("onetime", "usagelineitems", curencyCode, period, pageMaxSizeReconLineItems).Get();
var fetchNext = true;
ConsoleKeyInfo keyInfo;
var itemNumber = 1;
while (fetchNext)
{
Console.Out.WriteLine("\tLine items count: " + seekBasedResourceCollection.Items.Count());
seekBasedResourceCollection.Items.ToList().ForEach(item =>
{
// Instance of type DailyRatedUsageLineItem
if (item is DailyRatedUsageLineItem)
{
Type t = typeof(DailyRatedUsageLineItem);
PropertyInfo[] properties = t.GetProperties();
foreach (PropertyInfo property in properties)
{
// Insert code here to work with the line item properties
}
}
itemNumber++;
});
Console.Out.WriteLine("\tPress any key to fetch next data. Press the Escape (Esc) key to quit: \n");
keyInfo = Console.ReadKey();
if (keyInfo.Key == ConsoleKey.Escape)
{
break;
}
fetchNext = !string.IsNullOrWhiteSpace(seekBasedResourceCollection.ContinuationToken);
if (fetchNext)
{
if (seekBasedResourceCollection.Links.Next.Headers != null && seekBasedResourceCollection.Links.Next.Headers.Any())
{
seekBasedResourceCollection = scopedPartnerOperations.Invoices.ById("unbilled").By("onetime", "usagelineitems", curencyCode, period, pageMaxSizeReconLineItems).Seek(seekBasedResourceCollection.ContinuationToken, SeekOperation.Next);
}
}
}
Benzer bir örnek için bkz:
- Örnek: Konsol test uygulaması
- Project: İş Ortağı Merkezi SDK'sı Örnekleri
- Sınıf: GetUnBilledConsumptionReconLineItemsPaging.cs
REST isteği
İstek söz dizimi
Kullanım örneğiniz bağlı olarak REST isteğiniz için aşağıdaki söz dizimlerini kullanabilirsiniz. Daha fazla bilgi için her söz dizimi için açıklamalara bakın.
| Yöntem | İstek URI'si | Söz dizimi kullanım durumu açıklaması |
|---|---|---|
| AL | {baseURL}/v1/invoices/unbilled/lineitems?provider=onetime invoicelineitemtype=usagelineitems currencycode={currencycode} & period={period} HTTP/1.1 | Verilen faturanın her satır öğesinin tam listesini dönmek için bu söz dizimi kullanın. |
| AL | {baseURL}/v1/invoices/unbilled/lineitems?provider=onetime invoicelineitemtype=usagelineitems currencycode={currencycode} & period={period} & size={size} HTTP/1.1 | Büyük faturalar için bu söz dizimlerini kullanın. Satır öğelerinin sayfalı listesini geri dönmek için bu söz dizimi, belirtilen boyut ve 0 tabanlı kaydırma ile birlikte kullanın. |
| AL | {baseURL}/v1/invoices/unbilled/lineitems?provider=onetime invoicelineitemtype=usagelineitems currencycode={currencycode} & period={period} & size={size} & seekOperation=Next | kullanarak mutabakat satırı öğelerinin sonraki sayfasını almak için bu söz dizimi seekOperation = "Next" kullanın. |
URI parametreleri
İsteği oluştururken aşağıdaki URI'yi ve sorgu parametrelerini kullanın.
| Ad | Tür | Gerekli | Açıklama |
|---|---|---|---|
| Sağlayıcı | string | Yes | Sağlayıcı: "OneTime". |
| invoice-line-item-type | string | Yes | Fatura ayrıntısı türü: "UsageLineItems", "UsageLineItems". |
| currencyCode | string | Yes | İşlenemeyen satır öğelerinin para birimi kodu. |
| dönem | string | Yes | Bilgisiz mutabakat dönemi (örneğin: geçerli , önceki). Ocak ayında faturalama döneminin faturalanmamış kullanım verilerinizi sorgulamanız (01.01.2020 – 01.31.2020) olduğunu varsayalım. Dönem'i "Geçerli" olarak, "Önceki" olarak seçin. |
| boyut | sayı | No | İade etmek istediğiniz en fazla öğe sayısı. Varsayılan boyut 2000'tir. |
| seekOperation | dize | No | Mutabakat seekOperation=Next satırı öğelerinin sonraki sayfasını almak için ayarlayın. |
İstek üst bilgileri
Daha fazla bilgi için bkz. İş Ortağı Merkezi REST üst bilgileri.
İstek gövdesi
Yok.
REST yanıtı
Başarılı olursa yanıt, satır öğesi ayrıntıları koleksiyonunu içerir.
ChargeTypesatır öğesi için Purchase değeri Yeni ve Para İadesi değeri İptal ile eşlenmiş.
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 REST hata kodları.
İstek-yanıt örnekleri
İstek-yanıt örneği 1
Bu örnek için aşağıdaki ayrıntılar geçerlidir:
- Sağlayıcı:OneTime
- InvoiceLineItemType:UsageLineItems
- Dönem:Önceki
İstek örneği 1
GET https://api.partnercenter.microsoft.com/v1//invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems¤cycode=usd&period=previous&size=2000 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
X-Locale: en-US
MS-PartnerCenter-Application: Partner Center .NET SDK Samples
Host: api.partnercenter.microsoft.com
Yanıt örneği 1
HTTP/1.1 200 OK
Content-Length: 2484
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CV: bpqyomePDUqrSSYC.0
MS-ServerId: 202010406
Date: Wed, 20 Feb 2019 19:59:27 GMT
{
"totalCount": 2,
"items": [
{
"partnerId": "00083575-bbd0-54de-b2ad-0f5b0e927d71",
"partnerName": "MTBC",
"customerId": "",
"customerName": "",
"customerDomainName": "",
"invoiceNumber": "",
"productId": "",
"skuId": "",
"availabilityId": "",
"skuName": "VM-Series Next-Generation Firewall (Bundle 2 PAYG)",
"productName": "VM-Series Next Generation Firewall",
"publisherName": "Test Alto Networks, Inc.",
"publisherId": "",
"subscriptionId": "12345678-04d9-421c-baf8-e3b8dd62ddba",
"subscriptionDescription": "Pay-As-You-Go",
"chargeStartDate": "2019-01-01T00:00:00Z",
"chargeEndDate": "2019-02-01T00:00:00Z",
"usageDate": "2019-01-01T00:00:00Z",
"meterType": "1 Compute Hour - 4core",
"meterCategory": "Virtual Machine Licenses",
"meterId": "4core",
"meterSubCategory": "VM-Series Next Generation Firewall",
"meterName": "VM-Series Next Generation Firewall - VM-Series Next-Generation Firewall (Bundle 2 PAYG) - 4 Core Hours",
"meterRegion": "",
"unitOfMeasure": "1 Hour",
"resourceLocation": "EASTUS",
"consumedService": "Microsoft.Compute",
"resourceGroup": "ECH-PAN-RG",
"resourceUri": "/subscriptions/12345678-04d9-421c-baf8-e3b8dd62ddba/resourceGroups/ECH-PAN-RG/providers/Microsoft.Compute/virtualMachines/echpanfw",
"tags": "",
"additionalInfo": "{ \"ImageType\": null, \"ServiceType\": \"Standard_D3_v2\", \"VMName\": null, \"VMProperties\": null, \"UsageType\": \"ComputeHR_SW\"}",
"serviceInfo1": "",
"serviceInfo2": "",
"customerCountry": "",
"mpnId": "1234567",
"resellerMpnId": "",
"chargeType": "",
"unitPrice": 1.2799888920023,
"quantity": 24.0,
"unitType": "",
"billingPreTaxTotal": 30.7197334080551,
"billingCurrency": "USD",
"pricingPreTaxTotal": 30.7197334080551,
"pricingCurrency": "USD",
"entitlementId": "1234547f-b249-4edd-9319-637862d8c0b4",
"entitlementDescription": "Partner Subscription",
"pcToBCExchangeRate": 1,
"pcToBCExchangeRateDate": "2019-08-01T00:00:00Z",
"effectiveUnitPrice": 0,
"rateOfPartnerEarnedCredit": 0,
"rateOfCredit": 0,
"creditType": "Credit Not Applied",
"invoiceLineItemType": "usage_line_items",
"billingProvider": "marketplace",
"attributes": {
"objectType": "DailyRatedUsageLineItem"
}
},
{
"partnerId": "00083575-bbd0-54de-b2ad-0f5b0e927d71",
"partnerName": "MTBC",
"customerId": "",
"customerName": "",
"customerDomainName": "",
"invoiceNumber": "",
"productId": "",
"skuId": "",
"availabilityId": "",
"skuName": "VM-Series Next-Generation Firewall (Bundle 2 PAYG)",
"productName": "VM-Series Next Generation Firewall",
"publisherName": "Test Alto Networks, Inc.",
"publisherId": "",
"subscriptionId": "12345678-04d9-421c-baf8-e3b8dd62ddba",
"subscriptionDescription": "Pay-As-You-Go",
"chargeStartDate": "2019-01-01T00:00:00Z",
"chargeEndDate": "2019-02-01T00:00:00Z",
"usageDate": "2019-01-02T00:00:00Z",
"meterType": "1 Compute Hour - 4core",
"meterCategory": "Virtual Machine Licenses",
"meterId": "4core",
"meterSubCategory": "VM-Series Next Generation Firewall",
"meterName": "VM-Series Next Generation Firewall - VM-Series Next-Generation Firewall (Bundle 2 PAYG) - 4 Core Hours",
"meterRegion": "",
"unitOfMeasure": "1 Hour",
"resourceLocation": "EASTUS",
"consumedService": "Microsoft.Compute",
"resourceGroup": "ECH-PAN-RG",
"resourceUri": "/subscriptions/12345678-04d9-421c-baf8-e3b8dd62ddba/resourceGroups/ECH-PAN-RG/providers/Microsoft.Compute/virtualMachines/echpanfw",
"tags": "",
"additionalInfo": "{ \"ImageType\": null, \"ServiceType\": \"Standard_D3_v2\", \"VMName\": null, \"VMProperties\": null, \"UsageType\": \"ComputeHR_SW\"}",
"serviceInfo1": "",
"serviceInfo2": "",
"customerCountry": "",
"mpnId": "1234567",
"resellerMpnId": "",
"chargeType": "",
"unitPrice": 1.2799888920023,
"quantity": 24.0,
"unitType": "",
"billingPreTaxTotal": 30.7197334080551,
"billingCurrency": "USD",
"pricingPreTaxTotal": 30.7197334080551,
"pricingCurrency": "USD",
"entitlementId": "31cdf47f-b249-4edd-9319-637862d12345",
"entitlementDescription": "Partner Subscription",
"pcToBCExchangeRate": 1,
"pcToBCExchangeRateDate": "2019-08-01T00:00:00Z",
"effectiveUnitPrice": 0,
"rateOfPartnerEarnedCredit": 0,
"rateOfCredit": 1,
"creditType": "Azure Credit Applied",
"invoiceLineItemTypce": "usage_line_items",
"billingProvider": "marketplace",
"attributes": {
"objectType": "DailyRatedUsageLineItem"
}
}
],
"links": {
"self": {
"uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems¤cycode=usd&period=previous&size=2000",
"method": "GET",
"headers": []
},
"next": {
"uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems¤cycode=usd&period=previous&size=2000&seekOperation=Next",
"method": "GET",
"headers": [
{
"key": "MS-ContinuationToken",
"value": "AQAAAA=="
}
]
}
},
"attributes": {
"objectType": "Collection"
}
}
İstek-yanıt örneği 2
Bu örnek için aşağıdaki ayrıntılar geçerlidir:
- Sağlayıcı:OneTime
- InvoiceLineItemType:UsageLineItems
- Dönem:Önceki
- Seekoperation: İleri
İstek örneği 2
GET https://api.partnercenter.microsoft.com/v1/invoices/unbilled/lineitems?provider=onetime&invoiceLineItemType=usagelineitems¤cyCode=usd&period=previous&size=2000&seekoperation=next HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-ContinuationToken: d19617b8-fbe5-4684-a5d8-0230972fb0cf,0705c4a9-39f7-4261-ba6d-53e24a9ce47d_a4ayc/80/OGda4BO/1o/V0etpOqiLx1JwB5S3beHW0s=,0d81c700-98b4-4b13-9129-ffd5620f72e7
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
X-Locale: en-US
MS-PartnerCenter-Application: Partner Center .NET SDK Samples
Host: api.partnercenter.microsoft.com
Yanıt örneği 2
HTTP/1.1 200 OK
Content-Length: 2484
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CV: bpqyomePDUqrSSYC.0
MS-ServerId: 202010406
Date: Wed, 20 Feb 2019 19:59:27 GMT
{
"totalCount": 1,
"items": [
{
"partnerId": "00083575-bbd0-54de-b2ad-0f5b0e927d71",
"partnerName": "MTBC",
"customerId": "",
"customerName": "",
"customerDomainName": "",
"invoiceNumber": "",
"productId": "",
"skuId": "",
"availabilityId": "",
"skuName": "VM-Series Next-Generation Firewall (Bundle 2 PAYG)",
"productName": "VM-Series Next Generation Firewall",
"publisherName": "Test Alto Networks, Inc.",
"publisherId": "",
"subscriptionId": "12345678-04d9-421c-baf8-e3b8dd62ddba",
"subscriptionDescription": "Pay-As-You-Go",
"chargeStartDate": "2019-01-01T00:00:00Z",
"chargeEndDate": "2019-02-01T00:00:00Z",
"usageDate": "2019-01-02T00:00:00Z",
"meterType": "1 Compute Hour - 4core",
"meterCategory": "Virtual Machine Licenses",
"meterId": "4core",
"meterSubCategory": "VM-Series Next Generation Firewall",
"meterName": "VM-Series Next Generation Firewall - VM-Series Next-Generation Firewall (Bundle 2 PAYG) - 4 Core Hours",
"meterRegion": "",
"unitOfMeasure": "1 Hour",
"resourceLocation": "EASTUS",
"consumedService": "Microsoft.Compute",
"resourceGroup": "ECH-PAN-RG",
"resourceUri": "/subscriptions/12345678-04d9-421c-baf8-e3b8dd62ddba/resourceGroups/ECH-PAN-RG/providers/Microsoft.Compute/virtualMachines/echpanfw",
"tags": "",
"additionalInfo": "{ \"ImageType\": null, \"ServiceType\": \"Standard_D3_v2\", \"VMName\": null, \"VMProperties\": null, \"UsageType\": \"ComputeHR_SW\"}",
"serviceInfo1": "",
"serviceInfo2": "",
"customerCountry": "",
"mpnId": "1234567",
"resellerMpnId": "",
"chargeType": "",
"unitPrice": 1.2799888920023,
"quantity": 24.0,
"unitType": "",
"billingPreTaxTotal": 30.7197334080551,
"billingCurrency": "USD",
"pricingPreTaxTotal": 30.7197334080551,
"pricingCurrency": "USD",
"entitlementId": "31cdf47f-b249-4edd-9319-637862d8c0b4",
"entitlementDescription": "Partner Subscription",
"pcToBCExchangeRate": 1,
"pcToBCExchangeRateDate": "2019-08-01T00:00:00Z",
"effectiveUnitPrice": 0,
"rateOfPartnerEarnedCredit": 0.15,
"rateOfCredit": 0.15,
"creditType": "Partner Earned Credit Applied",
"invoiceLineItemType": "usage_line_items",
"billingProvider": "marketplace",
"attributes": {
"objectType": "DailyRatedUsageLineItem"
}
}
],
"links": {
"self": {
"uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems¤cycode=usd&period=previous&size=2000",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "Collection"
}
}