Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languageen

With this tutorial we aim to show you how to build .NET application using BellaDati analytics features through REST API. Main focus is on

      • OAuth authentication with BellaDati using xAuth method
      • BellaDati REST API calls
      • Processing of REST API (JSON and non-JSON format) 
      • Handling of BellaDati HTTP errors

We will use C# programming language to allow us to experiment lavishly with our code. 

Tutorial pre-requisites are

      • BellaDati application installed on your machine or cloud (min

このチュートリアルでは、どのようにREST APIを介してBellaDati分析機能を使用して.NETアプリケーションを構築する方法をお見せすることを目指しています。主な焦点は:

    • BellaDatiがXAUTH法を用いたOAuth認証
    • BellaDati REST API呼び出し
    • REST API処理(JSONと非JSON形式)
    • BellaDati HTTPエラーの取り扱い

私たちは私たちのコードで贅沢に試すことができるようにC#プログラミング言語を使用する。

チュートリアルの前提条件がある。

    • BellaDatiアプリケーションは、あなたのマシンまたはクラウド上にインストールした(min
      • .version 2.7.15.
    • 3)
    • はあなたのBellaDatiアプリケーションドメインで有効になって
    • BellaDatiデータウェアハウスは、ドメイン内の少なくとも3データセットとレポートが含まれている必要がある
    • C#でのプログラミングのためのVisual Studio 

 

      • enabled in your BellaDati application's domain
      • BellaDati data warehouse should contain at least 3 datasets and reports in your domain
      • Visual Studio for programming in C#

 

Firstly, we need to create a project in Visual Studio. It is WPF app in ourexample.まず、Visual Studioでプロジェクトを作成する。私達の例にWPFアプリです。

 

あなたのソリューションにBellaDatiBase.csとBellaDatiConnection.csを貼り付ける。

Image Removed

Paste the BellaDatiBase.cs and BellaDatiConnection.cs to your solution.

Image Added

After that, you can start with writing a code to the その後、MainWindow.xaml.cs. へのコードを書き込んで始める。あなたの創造によりXamlを作成できる。And you can create your xaml, base to your fantasy.

1.

 

 Obtain accessToken from BellaDati REST API

からaccessTokenを取る

Appropriate BellaDati endpoint for getting the oauth次のようにoauth_access_tokenを取得するための適切なBellaDatiエンドポイントが定義されている。token is defined as follows:

Code Block
themeMidnight
languagec#
public const string XAUTH_ACCESS_TOKEN = "/oauth/accessToken";

 

このThis oauth_access_token BellaDatiプラットフォームに対するすべての必然的な呼び出しのために必要とされる。それはis required for all consequent calls against BellaDati Platform. It is implemented in BellaDatiConnection.csに実装されている。.

In this example, let's assume that we have set up a domain with a consumer key mykey and a consumer secret apisecret. These keys set up to your App.config see below.この例では、我々はコンシューマキーにmykeyとコンシューマシークレットapisecret APIでドメインを設定していると仮定しましょう。これらのキーがあなたのApp.configファイルに設定する。以下を参照してください。

Code Block
themeMidnight
languagec#
<appSettings>
    <add key="consumerKey" value="mykey"/>
    <add key="consumerSecret" value="apisecret"/>
</appSettings>

今、あなたは私たちのサーバに接続し、認証できる。Now you can connect to our server and authenticate:

Code Block
themeMidnight
languagec#
BellaDatiConnection connection = new BellaDatiConnection("https://service.belladati.com");
connection.xAuthGetAccessToken(textBoxName.Text, pswdBox.Password);

2. Access REST API using HTTP GET

方法を使用ことでREST APIをアクセス

method

After the authentication you have an 認証後は、oauth_access_tokenを持っていて、使用可能なすべての保護されたREST APIのリソースにアクセスできる。例えば、レポート、ダッシュボード、ビューなどをGET。ここではGET Reportsについての例です。REST API Resourcesの下にすべての見つけるREST API。 and you can access all available protected REST API resources, e.g. GET reports, dashboards, views etc. Here is an example for GET Reports. All REST API you can find under REST API Resources.

 

Code Block
themeMidnight
languagec#
titleCall function doGet(url) from your created instance connection.
string data = connection.doGet("/api/reports");

 いくつか作成したレポートを持っている場合、この関数は、JSONでのREST APIからデータを返す以下を参照される。

If you have some created report, this function will return data from REST API in JSON see below.

 

私たちは、次の例に示すようにtry catch句を持つWe recommend to surround the function connection.doGet関数を囲むようにお勧めします。 with try catch clause as shown in example below.

Code Block
themeMidnight
languagec#
 	try
    {
      connection.xAuthGetAccessToken(textBoxName.Text, pswdBox.Password);
      string data = connection.doGet("/api/reports/47685");
      textBlockResponse.Text = data;
    }
	catch (Exception ee)
    {
      textBlockResponse.Text = ee.Message;
    }

 

エラーがあれば、いくつかのエラーボックスに表示される。

So If there is some error you will see it in some error box.

As a next step, you can display some chart as image次のステップとして、あなたは画像のようないくつかのチャートを表示できる:

Code Block
themeMidnight
languagec#
string data = connection.doGet("/api/reports/views/47685-XtFJ2yl9DX/image");

このRESTAPIのレスポンスは、PNG画像です。それはchart.pngに保存されて、それをPictureBoxにロードできる。The response of this REST API is png image. It will save it to chart.png and than you can load it to you pictureBox see below.

Code Block
themeMidnight
languagec#
  var uri = new Uri(@"chart.png");
  var bitmap = new BitmapImage(uri);
  pictureBox.Source = bitmap;
    
Info

イメージのパスを変更したい場合、BellaDatiConnectionクラスでそれを行うことができる。If you want to change the path of image, you can do it in class BellaDatiConnection.

 

 

 全体のでは、あなたが必要とするクラスが含まれている

The whole example includes the classes you need...

Sv translation
languageja

このチュートリアルでは、どのようにREST APIを介してBellaDati分析機能を使用して.NETアプリケーションを構築する方法をお見せすることを目指しています。主な焦点は:

    • BellaDatiがXAUTH法を用いたOAuth認証
    • BellaDati REST API呼び出し
    • REST API処理(JSONと非JSON形式)
    • BellaDati HTTPエラーの取り扱い

私たちは私たちのコードで贅沢に試すことができるようにC#プログラミング言語を使用する。

チュートリアルの前提条件がある。

    • BellaDatiアプリケーションは、あなたのマシンまたはクラウド上にインストールした(min.version 2.7.15.3)
    • REST API はあなたのBellaDatiアプリケーションドメインで有効になって
    • BellaDatiデータウェアハウスは、ドメイン内の少なくとも3データセットとレポートが含まれている必要がある
    • C#でのプログラミングのためのVisual Studio 

 

まず、Visual Studioでプロジェクトを作成する。私達の例にWPFアプリです。

 

あなたのソリューションにBellaDatiBase.csとBellaDatiConnection.csを貼り付ける。

その後、MainWindow.xaml.cs.へのコードを書き込んで始める。あなたの創造によりXamlを作成できる。

1.  BellaDati REST APIからaccessTokenを取る

次のようにoauth_access_tokenを取得するための適切なBellaDatiエンドポイントが定義されている。

Code Block
themeMidnight
languagec#
public const string XAUTH_ACCESS_TOKEN = "/oauth/accessToken";

 

このoauth_access_tokenBellaDatiプラットフォームに対するすべての必然的な呼び出しのために必要とされる。それはBellaDatiConnection.csに実装されている。

この例では、我々はコンシューマキーにmykeyとコンシューマシークレットapisecret APIでドメインを設定していると仮定しましょう。これらのキーがあなたのApp.configファイルに設定する。以下を参照してください。

Code Block
themeMidnight
languagec#
<appSettings>
    <add key="consumerKey" value="mykey"/>
    <add key="consumerSecret" value="apisecret"/>
</appSettings>

今、あなたは私たちのサーバに接続し、認証できる。

Code Block
themeMidnight
languagec#
BellaDatiConnection connection = new BellaDatiConnection("https://service.belladati.com");
connection.xAuthGetAccessToken(textBoxName.Text, pswdBox.Password);

2. HTTP GET方法を使用ことでREST APIをアクセス

認証後は、oauth_access_tokenを持っていて、使用可能なすべての保護されたREST APIのリソースにアクセスできる。例えば、レポート、ダッシュボード、ビューなどをGET。ここではGET Reportsについての例です。REST API Resourcesの下にすべての見つけるREST API。

 

Code Block
themeMidnight
languagec#
titleCall function doGet(url) from your created instance connection.
string data = connection.doGet("/api/reports");

 

いくつか作成したレポートを持っている場合、この関数は、JSONでのREST APIからデータを返す以下を参照される。

 

私たちは、次の例に示すようにtry catch句を持つconnection.doGet関数を囲むようにお勧めします。

Code Block
themeMidnight
languagec#
 	try
    {
      connection.xAuthGetAccessToken(textBoxName.Text, pswdBox.Password);
      string data = connection.doGet("/api/reports/47685");
      textBlockResponse.Text = data;
    }
	catch (Exception ee)
    {
      textBlockResponse.Text = ee.Message;
    }

 

エラーがあれば、いくつかのエラーボックスに表示される。

次のステップとして、あなたは画像のようないくつかのチャートを表示できる:

Code Block
themeMidnight
languagec#
string data = connection.doGet("/api/reports/views/47685-XtFJ2yl9DX/image");

このRESTAPIのレスポンスは、PNG画像です。それはchart.pngに保存されて、それをPictureBoxにロードできる。

Code Block
themeMidnight
languagec#
  var uri = new Uri(@"chart.png");
  var bitmap = new BitmapImage(uri);
  pictureBox.Source = bitmap;
    
Info

イメージのパスを変更したい場合、BellaDatiConnectionクラスでそれを行うことができる。

 

 

 

全体のでは、あなたが必要とするクラスが含まれている