請求書の課金されていないコマーシャル使用量の明細を取得する

Note

有効 2025 年 1 月 21 日、この API は非推奨になります。 継続性を確保するために移行を計画します。

  • 目標: 2025 年 1 月 21 日より前の現在および以前の請求期間について、未請求の毎日の使用状況の明細項目を取得します。

  • アクション: 2025 年 1 月 21 日 前にこの API を使用するか早く API v2 GA に移行します。

  • 目標: 2025 年 1 月 21 日 から、現在および以前の請求期間の未請求の毎日の使用状況の明細項目を取得

  • アクション: API v2 GA のみを使用します。

新しい API にシームレスに移行するには、次のリンクに従います: 毎日の課金および未請求の使用状況調整 API v2 (GA)

ご注意いただき、ありがとうございます。また、課金 API で引き続き成功することを楽しみにしています。

未請求の商用消費明細項目の詳細のコレクションを取得する方法。

次のメソッドを使用して、未請求の商用消費明細項目 (オープン使用状況明細とも呼ばれます) の詳細のコレクションをプログラムで取得できます。

重要

毎日評価される使用状況データには、次の製品の料金は含まれません。

  • Azure 予約
  • Azure 節約プラン
  • Office
  • Dynamics
  • Microsoft Power Apps
  • 永続的ソフトウェア
  • ソフトウェア サブスクリプション
  • Microsoft 以外またはマーケットプレースの SaaS 製品

Note

API またはパートナー センター ポータルを使用して、 非請求 日単位の使用明細項目にアクセスできます。 正確なデータを確保するには、最大 24 時間の可用性を確保します。 場所やメーターが使用状況を報告するタイミングによっては、さらに遅延が発生する可能性があります。

最初に、請求日単位の使用状況データの時間配信に優先順位を付けます。 場合によっては、前月の課金される使用状況データが使用可能になるまで、最新の日単位の評価された使用状況データが表示されないことがあります。 課金された使用状況データを受け取ったら、月の初めから更新された未請求の使用状況データをすべて取得できます。

私たちは可能な限り正確でタイムリーな情報を提供するよう努めるので、あなたの理解と忍耐を感謝しています。

前提条件

  • パートナー センターの認証に関するページで説明している資格情報。 このシナリオでは、スタンドアロン アプリとアプリ + ユーザーの両方の資格情報を使った認証がサポートされています。

C#

指定した請求書の明細を取得するには:

  1. ById メソッドを呼び出して、指定した請求書の請求書操作へのインターフェイスを取得します。
  2. Get または GetAsync メソッドを呼び出して、請求書オブジェクトを取得します。

invoice オブジェクトには、指定した請求書のすべての情報が含まれます。 Providerは、未請求の詳細情報 (たとえば、OneTime) のソースを識別します。 InvoiceLineItemType は、型 (たとえば、UsageLineItem) を指定します。

次のコード例では、 foreach ループを使用して、 InvoiceLineItems コレクションを処理します。 InvoiceLineItemTypeごとに、個別の行項目のコレクションが取得されます。

InvoiceDetail インスタンスに対応する行項目のコレクションを取得するには:

  1. インスタンスの BillingProvider および InvoiceLineItemTypeBy メソッドに渡します。
  2. Get または GetAsync メソッドを呼び出して、関連付けられている行項目を取得します。
  3. 次の例に示すように、コレクションを走査する列挙子を作成します。
// 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);
        }
    }
}

同様の例については、次を参照してください。

  • サンプル: Console テスト アプリ
  • プロジェクト: Partner Center SDK サンプル
  • クラス: GetUnBilledConsumptionReconLineItemsPaging.cs

REST 要求

要求の構文

ユース ケースに応じて、REST 要求に次の構文を使用できます。 詳細については、各構文の説明を参照してください。

認証方法 要求 URI 構文のユース ケースの説明
GET {baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems¤cycode={currencycode}>period={period} HTTP/1.1 この構文を使用して、特定の請求書のすべての明細の完全な一覧を返します。
GET {baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems>currencycode={currencycode}>period={period}>size={size} HTTP/1.1 大きな請求書には、この構文を使用します。 指定したサイズと 0 から始まるオフセットでこの構文を使用して、行項目のページングされたリストを返します。
GET {baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems>currencycode={currencycode}>period={period}>size={size}&seekOperation=Next この構文を使用して、 seekOperation = "Next"を使用して調整明細の次のページを取得します。

URI パラメーター

要求を作成するときは、次の URI とクエリ パラメーターを使用します。

名前 タイプ Required 説明
provider string はい プロバイダー: "OneTime"。
invoice-line-item-type string はい 請求書の詳細の種類: "UsageLineItems"、"UsageLineItems"。
currencyCode string はい 未請求明細の通貨コード。
期間 string はい 未請求の偵察の期間 (例: currentprevious)。 たとえば、1 月の支払いサイクル (2020 年 1 月 1 日から 2020 年 1 月 31 日) の未請求の使用状況データに対してクエリを実行し、期間を "現在"、"他の"前" として選択する必要があるとします。
size 数値 いいえ 返される項目の最大数。 既定のサイズは 2000 です。
seekOperation string いいえ 調整明細の次のページを取得するには、 seekOperation=Next を設定します。

要求ヘッダー

詳細については、「パートナー センター REST ヘッダー」を参照してください。

要求本文

なし。

REST 応答

成功した場合、応答には行項目の詳細のコレクションが含まれます。

行項目 ChargeType の場合、値 PurchaseNew にマップされ、値 RefundCancel にマップされます。

応答の成功とエラーのコード

各応答には、成功または失敗とその他のデバッグ情報を示す HTTP 状態コードが付属しています。 ネットワーク トレース ツールを使用して、このコード、エラーの種類、その他のパラメーターを読み取ります。 完全な一覧については、パートナー センターの REST エラーコードに関する記事を参照してください。

要求-応答の例

要求-応答の例 1

この例には、次の詳細が適用されます。

  • Provider: OneTime
  • InvoiceLineItemType: UsageLineItems
  • 期間: Previous

要求の例 1

GET https://api.partnercenter.microsoft.com/v1//invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=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

重要

2023 年 6 月の時点で、最新のパートナー センター .NET SDK リリース 3.4.0 がアーカイブされるようになりました。 SDK リリースは、有用な情報が記載された readme ファイルと一緒に GitHub からダウンロードできます。

パートナーは、引き続き Partner Center REST API を使用することをお勧めします。

応答の例 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": "3f47bcf1-965d-40a1-a2bc-3d5db3653250",
            "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",
        "benefitOrderId": "5ea053d6-4a0d-46ef-bc82-15065b475d01",
        "benefitId": "28ddab06-2c5b-479e-88bb-7b7bfda4e7fd",
        "benefitType": "SavingsPlan",
            "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",
        "benefitOrderId": "",
            "benefitId": "",
            "benefitType": "Charge",
            "attributes": {
                "objectType": "DailyRatedUsageLineItem"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000",
            "method": "GET",
            "headers": []
        },
        "next": {
            "uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000&seekOperation=Next",
            "method": "GET",
            "headers": [
                {
                    "key": "MS-ContinuationToken",
                    "value": "AQAAAA=="
                }
            ]
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}

要求-応答の例 2

この例には、次の詳細が適用されます。

  • Provider: OneTime
  • InvoiceLineItemType: UsageLineItems
  • 期間: Previous
  • SeekOperation: Next

要求の例 2

GET https://api.partnercenter.microsoft.com/v1/invoices/unbilled/lineitems?provider=onetime&invoiceLineItemType=usagelineitems&currencyCode=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

応答の例 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",
        "benefitOrderId": "",
            "benefitId": "",
            "benefitType": "Charge",
            "attributes": {
                "objectType": "DailyRatedUsageLineItem"
            }
        }
    ],
    "links": {
        "self": {
             "uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}