API Server とAPI ADO.NET Provider を使用して、Microsoft PowerPivot からAPI のデータにアクセス
この記事では、API Server を使用してMicrosoft Excel のPowerPivot ビジネスインテリジェンスツールでデータを活用する方法について説明します。以下のステップに従って、Power Pivot でAPI のデータを取得して編集します。
API Server の設定
以下のリンクからAPI Server の無償トライアルをスタートしたら、セキュアなAPI OData サービスを作成していきましょう。
API への接続
PowerPivot からAPI のデータを操作するには、まずyour API への接続を作成・設定します。
- API Server にログインして、「Connections」をクリック、さらに「接続を追加」をクリックします。
- 「接続を追加」をクリックして、データソースがAPI Server に事前にインストールされている場合は、一覧から「API」を選択します。
- 事前にインストールされていない場合は、コネクタを追加していきます。コネクタ追加の手順は以下の記事にまとめてありますので、ご確認ください。
CData コネクタの追加方法はこちら >> - それでは、API への接続設定を行っていきましょう!
-
To connect to your API, configure the following properties on the Global Settings page:
- In Authentication, select the Type and fill in the required properties
- In Headers, add the required HTTP headers for your API
- In Pagination, select the Type and fill in the required properties
After the configuring the global settings, navigate to the Tables to add tables. For each table you wish to add:
- Click "+ Add"
- Set the Name for the table
- Set Request URL to the API endpoint you wish to work with
- (Optional) In Parameters, add the required URL Parameters for your API endpoint
- (Optional) In Headers, add the required HTTP headers for the API endpoint
- In Table Data click " Configure"
- Review the response from the API and click "Next"
- Select which element to use as the Repeated Elements and which elements to use as Columns and click "Next"
- Preview the tabular model of the API response and click "Confirm"
- 接続情報の入力が完了したら、「保存およびテスト」をクリックします。
To connect to your API, configure the following properties on the Global Settings page:
- In Authentication, select the Type and fill in the required properties
- In Headers, add the required HTTP headers for your API
- In Pagination, select the Type and fill in the required properties
After the configuring the global settings, navigate to the Tables to add tables. For each table you wish to add:
- Click "+ Add"
- Set the Name for the table
- Set Request URL to the API endpoint you wish to work with
- (Optional) In Parameters, add the required URL Parameters for your API endpoint
- (Optional) In Headers, add the required HTTP headers for the API endpoint
- In Table Data click " Configure"
- Review the response from the API and click "Next"
- Select which element to use as the Repeated Elements and which elements to use as Columns and click "Next"
- Preview the tabular model of the API response and click "Confirm"
API Server のユーザー設定
次に、API Server 経由でAPI にアクセスするユーザーを作成します。「Users」ページでユーザーを追加・設定できます。やってみましょう。
- 「Users」ページで ユーザーを追加をクリックすると、「ユーザーを追加」ポップアップが開きます。
-
次に、「ロール」、「ユーザー名」、「権限」プロパティを設定し、「ユーザーを追加」をクリックします。
-
その後、ユーザーの認証トークンが生成されます。各ユーザーの認証トークンとその他の情報は「Users」ページで確認できます。
API 用のAPI エンドポイントの作成
ユーザーを作成したら、API のデータ用のAPI エンドポイントを作成していきます。
-
まず、「API」ページに移動し、
「 テーブルを追加」をクリックします。
-
アクセスしたい接続を選択し、次へをクリックします。
-
接続を選択した状態で、各テーブルを選択して確認をクリックすることでエンドポイントを作成します。
OData のエンドポイントを取得
以上でAPI への接続を設定してユーザーを作成し、API Server でAPI データのAPI を追加しました。これで、OData 形式のAPI データをREST API で利用できます。API Server の「API」ページから、API のエンドポイントを表示およびコピーできます。
さらに、「Settings」->「Server」をクリックし、Excel との互換性のために「デフォルトフォーマット」を「XML (Atom)」に設定します。
API Server ユーザーを認証する
作成するOData サービスを決定したら、「Settings」->「Users」とクリックしてユーザーを認証します。API Server は、認証トークンベースの認証を使用して、主要な認証スキームをサポートします。IP アドレスを使用してアクセスを制限することも可能です。デフォルトではローカルマシンへの接続のみが許可されます。SSL を使用すれば、接続の認証だけでなく暗号化も可能です。
Power Pivot でAPI テーブルをインポートする
以下のステップに従って、必要に応じて更新もできるテーブルをインポートします。
- Excel で「PowerPivot」タブの「PowerPivot Window」アイコンをクリックしてPowerPivot を開きます。
- 「Home」->「Get External Data」->「From Data Service」->「From OData Data Feed」とクリックします。
-
認証パラメータを追加します。「Advanced」をクリックして「Integrated Security」オプションを「Basic」に設定します。CData API Server にアクセスできるユーザーのユーザーID とパスワードを入力する必要があります。 パスワードをユーザーの認証トークンに設定します。
-
「Base URL」ボックスで、CData API Server のOData URL を入力します。例:http://localhost:8032/api.rsc
-
インポートするテーブルを選択し、「Finish」をクリックします。
Power Pivot でAPI のデータを操作することが可能になります。