Power AppsからPower Automateを呼び出した際に、「502 BadGateway, The server did not receive a response from an upstream server. Request tracking id ~~~」というエラーが出たと言われたで、対処法をメモ。
エラー
Power AppsからPower Automateを呼び出そうとしたとき、こんな502エラーが出ることがある。


Power Automate単体でのテストは成功しているときは、まず「Power Appへの応答」アクションの使い方をチェックする必要がある。
原因の一つ:Power Appsへの応答アクション
このエラーの原因の一つは「Power Appsへの応答」アクションが呼び出されていないこと。
例えばこんな単純なフローがあったとき、


「エラー時だけPower Appsにメッセージを返そう」として「Power Appsの応答アクション」の実行条件をフローが失敗したときのみにしていると、このエラーが起きる。


解消方法:成功時もPower Appsへの応答アクションを呼び出すようにする
解消方法は、(値を返す必要がなくても)成功時にも「Power Appsへの応答」アクションを呼び出すようにしてあげること。


するとPower AppsからPower Automateへの呼び出しは無事成功する。


おまけ:応答のスキーマは合わせる必要がある
Power Appへの応答の出力は、フローを通して一致させる必要がある。


そのため、エラー時と成功時でPower Appsへの応答を返したい場合は、こんな感じでJSONに詰めて応答し、Power Apps側でParseJSONを使用して応答を利用することになるかと。

