0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Power Automate Desktopの「Webサービスを呼び出します」アクションを使ってDomoのAPIを使ってみる(Dataset情報の取得)

Posted at

はじめに

前回の「Power Automate Desktopの「Webサービスを呼び出します」アクションを使ってDomoのAPIを使ってみる(アクセストークンの取得)」の続きとなります。
今回も詳細は弊社Webのブログに記載をしておりますので必要に応じて参照お願い致します。また「Domoって何よ?」って方向けに3分程度の手短な紹介ビデオを作っておりますので、是非ご覧ください。

Domoのご紹介-第1回 経営から現場まで、ビジネスユーザーに最適なDomoのご紹介
https://youtu.be/ZjfA6ODnR7g

Domo紹介ビデオリストはコチラ
https://www.youtube.com/playlist?list=PLCT26wue-Onk9Jp_SjEPzMb3EXr_W0x_o

DomoのDataSet APIで情報取得

今回はDomoのDataSet API(解説ページはhttps://developer.domo.com/docs/dataset-api-reference/dataset)からList DataSetsを用います。
下記のように前回取得したアクセストークンをAuthorization: bearer<your-valid-oauth-access-token>に指定し実行すると・・・

GET https://api.domo.com/v1/datasets?sort=name&offset=20&limit=10
Accept: application/json 
Authorization: bearer <your-valid-oauth-access-token>

下記のようにJSON形式でDataSet管理情報であるid、名前、行数、列数、・・・が取得可能です

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 948

[{
"id": "a7b2ceee-367e-48bd-a9b8-4ed485fcb16",
"name": "dev受注残高照会01",
"rows": 502645,
"columns": 86,
"owner": { "id": 879743153, "name": "アルファー太郎" },
"dataCurrentAt": "2021-11-11T06:44:54Z",
"createdAt": "2021-02-05T08:56:22Z",
"updatedAt": "2021-11-11T06:44:55Z",
"pdpEnabled": false
},
{
"id": "aa4af506-7a3d-40ed-853d-7b30089535c",
"name": "Base Metrics",
"rows": 731,
"columns": 18,
"owner": { "id": 879743153, "name": "アルファー花子" },
"dataCurrentAt": "2021-11-11T06:41:17Z",
"createdAt": "2021-10-20T05:26:52Z",
"updatedAt": "2021-11-11T06:41:18Z",
"pdpEnabled": false
},
{
"id": "5223cbd2-e221-483d-876d-317a7796a2d",
"name": "Location Metrics",
"rows": 148,
"columns": 20,
"owner": { "id": 879743153, "name": "アルファー" },
"dataCurrentAt": "2021-11-11T06:40:15Z",
"createdAt": "2021-10-20T05:28:38Z",
"updatedAt": "2021-11-11T06:40:15Z",
"pdpEnabled": false
}]

今回は上記からid、name、rows、colums、ownerのnameと、このRPA定義を実行した日時を、取得年月日として列に追加し、さらに取得年月日時分をファイル名に付け加え、c:\tmpに保存する仕様にしました。
Excelへの転記結果例

Power Automate Desktopでやっている事

以下のような流れで設定しています。

  • DomoのList DataSets APIの呼び出し
  • 返って来たjson形式のファイルを加工し易いようにオブジェクト変換
  • RPA定義実行日時をデータとして書き込み、保存ファイル名に付加するため現在日時を取得
  • EXCELを起動し1行目に項目名(ヘッダー)を書き込み
  • DomoのList DataSets APIで取得したデータを順番にEXCELへ転記
  • 取得年月日時分をファイル名に付け加えc:\tmpに保存

DomoのList DataSets APIの呼び出し

前回同様Domo APIで解説されている、下記のような表現を、どのようにPower Automate Desktopに設定するか?になります。

GET https://api.domo.com/v1/datasets?sort=name&offset=20&limit=10 
Accept: application/json 
Authorization: bearer <your-valid-oauth-access-token>

下記のように設定すると稼働しました。あくまでも例ですので、もっと上手なやり方もあると思います。

  • URL:https://api.domo.com/v1/datasets
  • メソッド:GET
  • 受け入れる:application/json
  • コンテンツタイプ:application/json
  • カスタムヘッダー:Authorization: bearerに半角スペース後に前回取得したアクセストークン
![Webサービスを呼び出します設定](https://alpcom.co.jp/cms/wp-content/uploads/1ベアラ後ろにアクセストークン.png)

カスタムヘッダーに指定するアクセストークンは60分程度で無効になるようですし、上記のように、いちいち指定していられないので、実際は前回画面に表示/ファイル保存しているアクセストークンを%accessToken%と言った変数を作成し、取得したアクセストークンを格納しAuthorization: bearer %accessToken%と指定すると良いと思います。

一番「キモ」になるAPI呼び出しは以上です。
返って来た値の処理の詳細は弊社Webのブログでご紹介しております。
https://alpcom.co.jp/blog/20211115/

0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?