Invoice 未請求の商業消費明細項目を取得するGet invoice unbilled commercial consumption line items

適用対象:Applies to:

  • パートナー センターPartner Center

未請求商業消費明細項目の詳細のコレクションを取得する方法。How to get a collection of unbilled commercial consumption line item details.

次のメソッドを使用して、未請求商業消費明細行項目 (オープンな使用状況の行項目とも呼ばれます) のコレクションをプログラムで取得できます。You can use the following methods to get a collection of details unbilled commercial consumption line items (also known as open usage line items) programmatically.

注意

日々の評価を受けた使用量は通常、パートナーセンターに表示されるか、API を使用してアクセスされるまでに24時間かかります。Daily-rated usage normally takes 24 hours to appear in Partner Center or to be accessed through the API.

前提条件Prerequisites

  • パートナー センターの認証に関するページで説明している資格情報。Credentials as described in Partner Center authentication. このシナリオでは、スタンドアロンアプリとアプリ + ユーザー資格情報の両方を使用した認証がサポートされています。This scenario supports authentication with both standalone App and App+User credentials.

  • 請求書の識別子。An invoice identifier. これにより、品目を取得する請求書が識別されます。This identifies the invoice for which to retrieve the line items.

C#C#

指定した請求書の品目を取得するには、次のようにします。To get the line items for the specified invoice:

  1. ByIdメソッドを呼び出して、指定された請求書の請求書操作へのインターフェイスを取得します。Call the ById method to get an interface to invoice operations for the specified invoice.

  2. GetまたはGetAsyncメソッドを呼び出して、請求書オブジェクトを取得します。Call the Get or GetAsync method to retrieve the invoice object.

Invoice オブジェクトには、指定した請求書のすべての情報が含まれています。The invoice object contains all of the information for the specified invoice. プロバイダーは、未請求詳細情報のソース (たとえば、 OneTime) を識別します。The Provider identifies the source of the unbilled detail information (for example, OneTime). InvoiceLineItemTypeは、型 (たとえば、 UsageLineItem) を指定します。The InvoiceLineItemType specifies the type (for example, UsageLineItem).

次のコード例では、 foreach ループを使用して、 InvoiceLineItems コレクションを処理します。The following example code uses a foreach loop to process the InvoiceLineItems collection. InvoiceLineItemTypeごとに、個別の行項目のコレクションが取得されます。A separate collection of line items is retrieved for each InvoiceLineItemType.

InvoiceDetailインスタンスに対応する品目のコレクションを取得するには、次のようにします。To get a collection of line items that correspond to an InvoiceDetail instance:

  1. インスタンスの プロバイダーInvoiceLineItemType を、 By メソッドに渡します。Pass the instance's BillingProvider and InvoiceLineItemType to the By method.

  2. GetまたはGetAsyncメソッドを呼び出して、関連付けられている行項目を取得します。Call the Get or GetAsync method to retrieve the associated line items.

  3. 次の例に示すように、列挙子を作成してコレクションを走査します。Create an enumerator to traverse the collection as shown in the following example.

// 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);
        }
    }
}

同様の例については、次を参照してください。For a similar example, see:

  • サンプル: コンソール テスト アプリSample: Console test app
  • プロジェクト: パートナーセンター SDK のサンプルProject: Partner Center SDK Samples
  • クラス: GetUnBilledConsumptionReconLineItemsPaging.csClass: GetUnBilledConsumptionReconLineItemsPaging.cs

REST 要求REST request

要求の構文Request syntax

お使いのユースケースに応じて、REST 要求に対して次の構文を使用できます。You can use the following syntaxes for your REST request, depending on your use case. 詳細については、各構文の説明を参照してください。For more information, see the descriptions for each syntax.

MethodMethod 要求 URIRequest URI 構文のユースケースの説明Description of syntax use case
GETGET {baseURL}/v1/invoices/unbilled/lineitems? provider = onetime&invoicelineitemtype = usagelineitems&currencycode = {currencycode} &period = {PERIOD} HTTP/1.1{baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode={currencycode}&period={period} HTTP/1.1 この構文を使用して、指定された請求書のすべての品目の完全な一覧を返します。Use this syntax to return a full list of every line item for the given invoice.
GETGET {baseURL}/v1/invoices/unbilled/lineitems? provider = onetime&invoicelineitemtype = usagelineitems&currencycode = {currencycode} &period = {period} &size = {SIZE} HTTP/1.1{baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode={currencycode}&period={period}&size={size} HTTP/1.1 この構文は、大きな請求書に使用します。Use this syntax for large invoices. この構文を指定したサイズと0から始まるオフセットを使用して、行項目のページ化されたリストを返します。Use this syntax with a specified size and 0-based offset to return a paged list of line items.
GETGET {baseURL}/v1/invoices/unbilled/lineitems? provider = onetime&invoicelineitemtype = usagelineitems&currencycode = {currencycode} &period = {period} &size = {size} &Seekoperation = Next{baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode={currencycode}&period={period}&size={size}&seekOperation=Next この構文を使用すると、を使用して、調整行項目の次のページを取得 seekOperation = "Next" できます。Use this syntax to get the next page of reconciliation line items using seekOperation = "Next".

URI パラメーターURI parameters

要求の作成時には、次の URI とクエリパラメーターを使用します。Use the following URI and query parameters when creating the request.

名前Name 種類Type 必須Required 説明Description
providerprovider stringstring はいYes プロバイダー: "OneTime"。The provider: "OneTime".
invoice-line-item-typeinvoice-line-item-type stringstring はいYes 請求書の詳細の種類: "UsageLineItems"、"UsageLineItems"。The type of invoice detail: "UsageLineItems", "UsageLineItems".
currencyCodecurrencyCode stringstring はいYes 未請求の品目の通貨コード。The currency code for the unbilled line items.
periodperiod stringstring はいYes 未請求偵察の期間 (例: current, previous)。The period for unbilled recon (for example: current, previous).

[前へ] –請求サイクルが 01/01/2020 ~ 01/31/2020 の場合、通常、請求書は02/06/2020 と02/08/2020 の UTC 時間の間に生成されます。Previous – if the billing cycle is 01/01/2020 – 01/31/2020 then, most likely that your invoice is generated between 02/06/2020 and 02/08/2020 UTC time. 02/01/2020 と請求書によって生成された日付 (02/06/2020 と 02/08/2020 UTC 時刻) の間に、請求サイクルの未請求使用状況データ (01/01/2020 ~ 01/31/2020) を照会する必要がある場合は、[前] として [期間] を選択する必要があります。If you need to query your unbilled usage data of the billing cycle (01/01/2020 – 01/31/2020) on any time between 02/01/2020 and the invoice-generated date (which is between 02/06/2020 and 02/08/2020 UTC time), then, you need to choose Period as "Previous".

Current –請求サイクルが 01/01/2020 ~ 01/31/2020 である場合、通常、請求書は02/06/2020 と02/08/2020 の UTC 時間の間に生成されます。Current – if the billing cycle is 01/01/2020 – 01/31/2020 then, most likely that your invoice is generated between 02/06/2020 and 02/08/2020 UTC time. 請求サイクル内の01/01/2020 から01/31/2020 までの任意の時間に、請求サイクル (01/01/2020 ~ 01/31/2020) の未請求使用状況データを照会する必要がある場合は、[現在] として [期間] を選択する必要があります。If you need to query your unbilled usage data of the billing cycle (01/01/2020 – 01/31/2020) on any time between 01/01/2020 and 01/31/2020 which is within your billing cycle, then, you need to choose Period as "Current".
sizesize numbernumber いいえNo 返される項目の最大数。The maximum number of items to return. 既定のサイズは2000です。The default size is 2000.
seekOperationseekOperation stringstring いいえNo を設定し seekOperation=Next て、調整行項目の次のページを取得します。Set seekOperation=Next to get the next page of reconciliation line items.

要求ヘッダーRequest headers

詳細については、「パートナー センター REST ヘッダー」を参照してください。For more information, see Partner Center REST headers.

[要求本文]Request body

[なし] :None.

REST 応答REST response

成功した場合、応答には行項目の詳細のコレクションが含まれます。If successful, the response contains the collection of line item details.

行項目 ChargeTypeの場合、 購入 した値は 新規 にマップされ、値の 返金キャンセルにマップされます。For the line item ChargeType, the value Purchase is mapped to New and the value Refund is mapped to Cancel.

応答の成功とエラーのコードResponse success and error codes

各応答には、成功または失敗を示す HTTP ステータス コードと、追加のデバッグ情報が付属しています。Each response comes with an HTTP status code that indicates success or failure and additional debugging information. このコード、エラーの種類、追加のパラメーターを読み取るには、ネットワーク トレース ツールを使用します。Use a network trace tool to read this code, error type, and additional parameters. 完全な一覧については、パートナー センターの REST エラーコードに関する記事を参照してください。For the full list, see Partner Center REST error codes.

要求-応答の例Request-response examples

要求-応答の例1Request-response example 1

この例には、次の詳細が適用されます。The following details apply to this example:

  • プロバイダー: OneTimeProvider: OneTime
  • InvoiceLineItemType: UsageLineItemsInvoiceLineItemType: UsageLineItems
  • 期間: 前へPeriod: Previous

要求の例1Request example 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

応答の例1Response example 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,
            "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,
            "invoiceLineItemType": "usage_line_items",
            "billingProvider": "marketplace",
            "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"
    }
}

要求-応答の例2Request-response example 2

この例には、次の詳細が適用されます。The following details apply to this example:

  • プロバイダー: OneTimeProvider: OneTime
  • InvoiceLineItemType: UsageLineItemsInvoiceLineItemType: UsageLineItems
  • 期間: 前へPeriod: Previous
  • Seekoperation: SeekOperation: Next

要求の例2Request example 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

応答の例2Response example 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,
            "invoiceLineItemType": "usage_line_items",
            "billingProvider": "marketplace",
            "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"
    }
}