1
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?

【Power Apps】アプリからWeb APIを呼び出す方法&ユーザー定義型の活用

Posted at

Power AppsからWeb APIを呼び出す方法と応答の活用

Power AppsのアプリからWeb APIを呼び出す方法を2つ紹介します。
APIの応答はユーザー定義型を活用するととても便利なので、こちらについても紹介します。

この記事は Microsoft Power Apps Advent Calendar 2024 シリーズ1 12月20日 担当分の記事です。

画像を表示するAPI

猫画像API

こちらの記事で知った面白APIです。

画像コントロールのImageプロパティに設定したり、

image.png

リッチテキストエディタやHTMLテキストに画像埋め込みしたりすることで画像表示が可能です。

image.png

QR code API

ギークさんが以前紹介していたQR code APIをアプリから実行する方法です。

Power AutomateでOneDriveコネクタのURLからのファイルのアップロード&パスによるファイルコンテンツの取得を用いてQRコード画像を取得しています。

image.png

もちろん画像コントロールでもQRコードを表示できます。

image.png

オブジェクトを返すAPI

私の知る限りPower Apps単独ではオブジェクトを返すAPIは実行できなさそうなので(カスタムコネクタなど除く)、Power Automateを用いてAPIを呼び出します。

なおユーザー定義型という試験段階機能を利用しておりますので、利用の際にはご注意ください。

HTTP(有償)

image.png

有償ライセンスが必要ですが、HTTPアクションを用いてGET要求を行うのが正攻法です。

[動画: APIの実行デモ]

フロー作成、Power Appsに取込後、以下のユーザー定義型をApp.Formulasに設定。

ZipCodeDef := Type({
    message: Text,
    results: [{
        address1: Text,
        address2: Text,
        address3: Text,
        kana1: Text,
        kana2: Text,
        kana3: Text,
        prefcode: Text,
        zipcode: Text
    }],
    status: Number
});

動作プロパティにこちらを設定することで郵便番号APIを実行することができます。

Set(_ZipCode, ParseJSON(郵便番号.Run("2520318").response, ZipCodeDef).results)

OneDriveコネクタを利用(無償だがGETのみ)

前述のギークさんが紹介している方法でもGET要求のみAPIを実行することができます。
詳しくは以下の記事のシリーズをご覧ください。

元記事

1
1
0

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
1
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?