顧客の一覧を取得する

適用対象: パートナー センター | 21Vianet が運営するパートナー センター | Microsoft Cloud for US Government のパートナー センター

この記事では、パートナーのすべての顧客を表すリソースのコレクションを取得する方法について説明します。

ヒント

パートナー センターでこの操作を実行することもできます。 [ホーム] ページで、[ 顧客 ] ワークスペースを選択し、メニューの [ 顧客] リスト を使用して顧客を表示します。

前提条件

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

C#

すべての顧客の一覧を取得するには:

  1. IAggregatePartner.Customers コレクションを使用して、IPartner オブジェクトを作成します。

  2. Query() メソッドまたは QueryAsync() メソッドを使用して顧客リストを取得します。 (クエリを作成する手順については、 QueryFactory クラスを参照してください)。

// IAggregatePartner partnerOperations;

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

// read customers into chunks of 40s
var customersBatch = scopedPartnerOperations.Customers.Query(QueryFactory.Instance.BuildIndexedQuery(40));
var customersEnumerator = scopedPartnerOperations.Enumerators.Customers.Create(customersBatch);

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

Java

パートナー センター Java SDK を使用して、パートナー センター リソースを管理できます。 これは、パートナー コミュニティによって管理され、Microsoft によって正式にサポートされていないオープンソース プロジェクトです。 問題が発生した場合は、コミュニティから支援を得るか、GitHub に問題を投稿することができます。

すべての顧客の一覧を取得するには:

  1. [IAggregatePartner.getCustomers] 関数を使用して、顧客の操作への参照を取得します。

  2. query() 関数を使用して顧客リストを取得します。

// Query the customers, get the first page if a page size was set, otherwise get all customers
SeekBasedResourceCollection<Customer> customersPage = partnerOperations.getCustomers().query(QueryFactory.getInstance().buildIndexedQuery(40));

// Create a customer enumerator which will aid us in traversing the customer pages
IResourceCollectionEnumerator<SeekBasedResourceCollection<Customer>> customersEnumerator =
    partnerOperations.getEnumerators().getCustomers().create( customersPage );

int pageNumber = 1;

while (customersEnumerator.hasValue())
{
    /*
     * Use the customersEnumerator.getCurrent() function to
     * access the current page of customers.
     */

    // Get the next page of customers
    customersEnumerator.next();
}

PowerShell

パートナー センター PowerShell モジュールを使用して、パートナー センター リソースを管理できます。 これは、パートナー コミュニティによって管理され、Microsoft によって正式にサポートされていないオープンソース プロジェクトです。 問題が発生した場合は、コミュニティから支援を得るか、GitHub に問題を投稿することができます。

パラメーターなしで Get-PartnerCustomer コマンドを実行して、顧客の完全な一覧を取得します。

Get-PartnerCustomer

REST 要求

要求の構文

認証方法 要求 URI
GET {baseURL}/v1/customers?size={size} HTTP/1.1

URI パラメーター

顧客の一覧を取得するには、次のクエリ パラメーターを使用します。

名前 Type 必須 説明
size int Y 一度に表示される結果の数。

要求ヘッダー

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

[要求本文]

なし。

要求の例

GET https://api.partnercenter.microsoft.com/v1/customers?size=40 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 3705fc6d-4127-4a87-bdba-9658f73fe019
MS-CorrelationId: b12260fb-82de-4701-a25f-dcd367690645

REST 応答

成功した場合、このメソッドは応答本文で Customer リソースのコレクションを返します。

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

各応答には、成功または失敗を示す HTTP ステータス コードと、追加のデバッグ情報が付属しています。 このコード、エラーの種類、追加のパラメーターを読み取るには、ネットワーク トレース ツールを使用します。 完全な一覧については、「 エラー コード」を参照してください。

応答の例

HTTP/1.1 200 OK
Content-Length: 15650
Content-Type: application/json
MS-CorrelationId: b12260fb-82de-4701-a25f-dcd367690645
MS-RequestId: 3705fc6d-4127-4a87-bdba-9658f73fe019
Date: Fri, 20 Nov 2015 01:08:23 GMT

{
    "totalCount": 2,
    "items": [{
        "id": "b44bb1fb-c595-45b0-9e09-d657365580bf",
        "companyProfile": {
            "tenantId": "<guid>",
            "domain": "domain",
            "companyName": "companyName",
            "attributes": {
                "objectType": "CustomerCompanyProfile"
            }
        },
        "relationshipToPartner": "reseller",
        "attributes": {
            "objectType": "Customer"
        }
    },
    {
        "id": "45c44870-ef77-4fdd-b6fe-3dacb075cff2",
        "companyProfile": {
            "tenantId": "<guid>",
            "domain": "domain",
            "companyName": "companyName",
            "attributes": {
                "objectType": "CustomerCompanyProfile"
            }
        },
        "relationshipToPartner": "reseller",
        "attributes": {
            "objectType": "Customer"
        }
    }],
    "links": {
        "self": {
            "uri": "/v1/customers?size=40",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}