Page History
Sv translation | |||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
With this tutorial we aim to show you how to build .NET application using BellaDati analytics features through REST API. Main focus is on
We will use C# programming language to allow us to experiment lavishly with our code. Tutorial pre-requisites are
Firstly, we need to create a project in Visual Studio. It is WPF app in ourexample.
Paste the BellaDatiBase.cs and BellaDatiConnection.cs to your solution. After that, you can start with writing a code to the MainWindow.xaml.cs. And you can create your xaml, base to your fantasy. 1. Obtain accessToken from BellaDati REST APIAppropriate BellaDati endpoint for getting the oauth_access_token is defined as follows:
This oauth_access_token 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.
Now you can connect to our server and authenticate:
2. Access REST API using HTTP GET methodAfter the authentication you have an oauth_access_token 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.
If you have some created report, this function will return data from REST API in JSON see below.
We recommend to surround the function connection.doGet with try catch clause as shown in example below.
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:
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.
The whole example includes the classes you need... |
Sv translation | |||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
このチュートリアルでは、REST APIを介してBellaDati分析機能を使用して.NETアプリケーションを構築する方法をお見せすることを目指しています。主な焦点は:
私たちは私たちのコードで贅沢に試すことができるようにC#プログラミング言語を使用します。 チュートリアルの前提条件は
まず、Visual Studioでプロジェクトを作成します。私達の例にWPFアプリです。
あなたのソリューションにBellaDatiBase.csとBellaDatiConnection.csを貼り付けます。 その後、MainWindow.xaml.cs.へのコードを書き込んで始めます。あなたの創造によりXamlを作成できます。 1. BellaDati REST APIからaccessTokenを取得すること次のようにoauth_access_tokenを取得するための適切なBellaDatiエンドポイントが定義されます。
このoauth_access_tokenはBellaDatiプラットフォームに対してすべての必然的な呼び出しのために必要とされます。それはBellaDatiConnection.csに実装されます。 この例では、我々はコンシューマキーにmykeyとコンシューマシークレットapisecretAPIでドメインを設定していると仮定しましょう。これらのキーがあなたのApp.configファイルに設定します。以下を参照してください。
今、あなたは私たちのサーバに接続し、認証できます。
2. HTTP GET方法を使用ことでREST APIをアクセス認証後は、oauth_access_tokenを持って、GETレポート、ダッシュボード、ビューなど使用可能なすべての保護されたREST APIのリソースにアクセスできます。、。ここではGET Reportsについての例です。REST API Resourcesの下にすべてREST APIを見つけます。
いくつか作成されたレポートを持っている場合、この関数は以下のようにJSONでのREST APIからデータを返却します。
私たちは、次の例に示すようにtry catch句を持つconnection.doGet関数を囲むようにお勧めします。
エラーがあれば、いくつかのエラーボックスに表示されます。 次のステップとして、あなたは画像のようないくつかのチャートを表示できます:
このRESTAPIのレスポンスは、PNG画像です。それはchart.pngに保存されて、それをPictureBoxにロードできます。
全体の例では、あなたがほしいクラスが含まれます。 REST APIはあなたのBellaDatiアプリケーションドメインで有効になる |