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?

SlackのFilles.upload廃止に伴うPowerAutomateの移行方法

Posted at

files.uploadメソッドが2025/5に廃止になると聞いて、移行方法をいろいろ探していた。
今までは、PowerAutomateDesktopを利用してファイルをOnedriveにアップロードし、それをPowerAutomateのHTTPリクエストを利用してSlackに送信していたわけなのだが(参考)、HTTPリクエストで送ろうとするとエラーが頻発する。
仕方がないのでこちらのサイトを参考に、Slackのヘルプリクエストにも助けてもらいながら、PowerAutomateDesktopを利用してなんとか実装することに成功した。
備忘録兼、同様に困っている人のためにメモとして残しておく。

PADでの方法がこちら。

  1. アップロードしたいファイルの取得
  2. ファイル・パスの取得
  3. BotTokenを変数Tokenとして設定
  4. チャンネルIDを変数Channelとして設定
  5. 変数Command1に、以下のコマンドを設定
curl  https://slack.com/api/files.getUploadURLExternal -F token=%Token%  -F length=%Files[0].size% -F filename=%FileName%

6. DOSコマンドの実行から、Command1を実行
7. 変数→JSONをカスタム・オブジェクトに変換を利用し、Command1のCommandOutputを分解
8. 変数Command2に、以下のコマンドを設定

curl  -XPOST %JsonAsCustomObject['upload_url']% --data-binary @%Files[0]%

9. DOSコマンドの実行から、Command2を実行
10. 変数Command3に、以下のコマンドを設定

curl -X POST -H "Authorization: Bearer %Token%" -F "channel_id=%Channel%" -F "files=[{\"id\":\"%JsonAsCustomObject['file_id']%\", \"title\":\"%FileName%\"}]" -F "filename=@%Directory%\%FileName%" https://slack.com/api/files.completeUploadExternal

11.DOSコマンドの実行から、Command3を実行

以上の方法でファイル送信に成功した。
Slack_test.png

注意点としては、DOSコマンド実行のため整形で折り曲げる際は\ではなく^を付けないと失敗することぐらいか。

以上、備忘録として書き残しておく。

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