背景
Power BI の購読を週次展開する際に、サムネイルリンクだけだと、サムネイルが一定期間後に削除されてしまう(?)と見れなくなってしまう。
この対策の為に行った以下のまとめ
- サムネイル付ファイル添付
- 画像埋め込こみ
イメージ
結論
外観
補足
貼り付け&添付での返信
こっちは、画像貼り付け用の content を取得しようとしてる為、元データが 画像じゃないとダメ。
sites/{site-id}/drive/items/{item-id}/thumbnails/{thumb-id}/{size}
これで、thumbnail は取得出来るが、content 取得がうまくいかず、ちょっと放置
- 入力の使いまわし
- attachement id には eTag
{etag} 後ろのバージョン番号と、quotation の削除
@{first(split(replace(outputs('Get_file_metadata_using_path')?['body/ETag'],'"',''),','))
}
ファイル添付での返信
画像以外のファイルでも有効だけど
thumbnail が表示されるときとされないときの差がよくわからない
- content url の取得
{link} の後ろのパラメータを削除
@{first(split(body('Get_file_properties')?['{Link}'], '?'))}
sample code
貼り付け用
{"nodeId":"Scope-copy","serializedOperation":{"type":"Scope","actions":{"Scope_埋め込み":{"type":"Scope","actions":{"Send_a_Microsoft_Graph_HTTP_request":{"type":"OpenApiConnection","inputs":{"parameters":{"Uri":"https://graph.microsoft.com/v1.0/teams/@{outputs('Compose_teamId')}/channels/@{outputs('Compose_channelId')}/messages/@{outputs('Compose_messageId')}/replies","Method":"POST","Body":"{\n \"body\": {\n \"contentType\": \"html\",\n \"content\": \"最新状況\n<img src=\\\"../hostedContents/1/$value\\\"></img>\n<attachment id=\\\"@{outputs('Compose_eTag')}\\\"></attachment>\"\n },\n \"attachments\": [\n {\n // \"content\": \"string\",\n \"contentType\": \"reference\",\n \"contentUrl\": \"@{body('Get_file_properties')?['{Link}']}\",\n \"id\": \"@{outputs('Compose_eTag')}\",\n \"name\": \"@{outputs('Get_file_metadata_using_path')?['body/DisplayName']}\",\n // \"teamsAppId\": \"string\",\n \"thumbnailUrl\": \"@{body('Get_file_properties')?['{Thumbnail}']?['Large']}\"\n }\n ],\n \"hostedContents\":[\n {\n \"@microsoft.graph.temporaryId\": \"1\",\n \"contentBytes\": \"@{body('Get_file_content')['$content']}\",\n \"contentType\": \"@{body('Get_file_content')['$content-type']}\"\n }\n ]\n}\n","ContentType":"application/json"},"host":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_teams","connection":"shared_teams-3","operationId":"HttpRequest"}},"runtimeConfiguration":{"staticResult":{"staticResultOptions":"Disabled","name":"Send_a_Microsoft_Graph_HTTP_request0"}},"metadata":{"operationMetadataId":"7d0700b8-7c17-4446-89e4-56f6ce29826e"}}},"runAfter":{"Scope_投稿ファイル情報":["Succeeded"]}},"Scope_サムネイル付添付":{"type":"Scope","actions":{"Compose_{Link}":{"type":"Compose","inputs":"@first(split(body('Get_file_properties')?['{Link}'], '?'))","metadata":{"operationMetadataId":"f38d9e98-8aef-4a4f-a5e7-a403b55a84d5"}},"Send_a_Microsoft_Graph_HTTP_request_only_attachment":{"type":"OpenApiConnection","inputs":{"parameters":{"Uri":"https://graph.microsoft.com/v1.0/teams/@{outputs('Compose_teamId')}/channels/@{outputs('Compose_channelId')}/messages/@{outputs('Compose_messageId')}/replies","Method":"POST","Body":"{\n \"body\": {\n \"contentType\": \"html\",\n \"content\": \"最新状況\n\n<attachment id=\\\"@{outputs('Compose_eTag')}\\\"></attachment>\"\n },\n \"attachments\": [\n {\n // \"content\": \"string\",\n \"contentType\": \"reference\",\n \"contentUrl\": \"@{body('Get_file_properties')?['{FullPath}']}\",\n \"id\": \"@{outputs('Compose_eTag')}\",\n \"name\": \"@{outputs('Get_file_metadata_using_path')?['body/DisplayName']}\",\n // \"teamsAppId\": \"string\",\n \"thumbnailUrl\": \"@{body('Get_file_properties')?['{Thumbnail}']?['Large']}\"\n }\n ]\n}\n","ContentType":"application/json"},"host":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_teams","connection":"shared_teams-3","operationId":"HttpRequest"}},"runAfter":{"Compose_{Link}":["Succeeded"]},"runtimeConfiguration":{"staticResult":{"staticResultOptions":"Disabled","name":"Send_a_Microsoft_Graph_HTTP_request0"}},"metadata":{"operationMetadataId":"ce2b20d1-a514-48d4-8b3c-900e113edde9"}}},"runAfter":{"Scope_投稿ファイル情報":["Succeeded"]}},"Scope_投稿先情報用":{"type":"Scope","actions":{"Get_messages":{"type":"OpenApiConnection","inputs":{"parameters":{"groupId":"a70cc9a6-85a4-4b73-974a-c005f11ca2b5","channelId":"19:f243c3cf57aa4845983306279f8649e5@thread.tacv2"},"host":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_teams","connection":"shared_teams-1","operationId":"GetMessagesFromChannel"}},"metadata":{"operationMetadataId":"862c0552-aa59-44b7-9816-735d7cf8071b"}},"Compose_teamId":{"type":"Compose","inputs":"@actions('Get_messages')?.inputs.parameters['groupId']\r\n","runAfter":{"Get_messages":["Succeeded"]},"metadata":{"operationMetadataId":"f140bec1-e484-4331-b8b5-63defb7a61e3"}},"Compose_channelId":{"type":"Compose","inputs":"@actions('Get_messages')?.inputs.parameters['channelId']\r\n","runAfter":{"Get_messages":["Succeeded"]},"metadata":{"operationMetadataId":"60264bea-dc37-41f5-af94-599c034c2172"}},"Compose_messageId":{"type":"Compose","inputs":1720960263348,"runAfter":{"Get_messages":["Succeeded"]},"metadata":{"operationMetadataId":"2acd282e-9ac2-466a-8c73-c30cbbf7b8cc"}}}},"Scope_投稿ファイル情報":{"type":"Scope","actions":{"Get_file_metadata_using_path":{"type":"OpenApiConnection","inputs":{"parameters":{"dataset":"https://shimakuma.sharepoint.com/sites/TestForTeams","path":"/Shared Documents/TestForRetreivingByPowerBI/SampleFile (10).xlsx"},"host":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline","connection":"shared_sharepointonline-1","operationId":"GetFileMetadataByPath"}},"metadata":{"operationMetadataId":"37ff9a1e-7d30-4373-96d6-0ef65d0c79e4"}},"Compose_dataset":{"type":"Compose","inputs":"@actions('Get_file_metadata_using_path')?.inputs.parameters['dataset']","runAfter":{"Get_file_metadata_using_path":["Succeeded"]},"metadata":{"operationMetadataId":"a5c5df02-99ff-4ede-a7ea-90e1ac5f2e02"}},"Compose_eTag":{"type":"Compose","inputs":"@first(split(replace(outputs('Get_file_metadata_using_path')?['body/ETag'],'\"',''),','))\r\n\r\n","runAfter":{"Get_file_metadata_using_path":["Succeeded"]},"metadata":{"operationMetadataId":"43fd7de1-4a76-47ac-b302-35f9b3f10f67"}},"Get_file_properties":{"type":"OpenApiConnection","inputs":{"parameters":{"dataset":"@outputs('Compose_dataset')","table":"Documents","id":"@outputs('Get_file_metadata_using_path')?['body/ItemId']"},"host":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline","connection":"shared_sharepointonline-2","operationId":"GetFileItem"}},"runAfter":{"Compose_dataset":["Succeeded"]},"metadata":{"operationMetadataId":"35cbd999-edb3-45c0-ab14-67b2b0e2478d"}},"Get_file_content":{"type":"OpenApiConnection","inputs":{"parameters":{"dataset":"@outputs('Compose_dataset')","id":"@outputs('Get_file_metadata_using_path')?['body/Id']","inferContentType":true},"host":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline","connection":"shared_sharepointonline-1","operationId":"GetFileContent"}},"runAfter":{"Compose_dataset":["Succeeded"]},"metadata":{"operationMetadataId":"9847563d-18a7-4cd8-94e1-bdace7e69278"}}},"runAfter":{"Scope_投稿先情報用":["Succeeded"]}}},"runAfter":{},"metadata":{"operationMetadataId":"1d59992c-3ee8-48a5-a8ab-49eccea6334a"}},"allConnectionData":{"Send_a_Microsoft_Graph_HTTP_request":{"connectionReference":{"api":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams"},"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-c9efbf63-e5a2-4102-a864-e913ec0c8ef8"},"connectionName":"shared-teams-c9efbf63-e5a2-4102-a864-e913ec0c8ef8"},"referenceKey":"shared_teams-3"},"Send_a_Microsoft_Graph_HTTP_request_only_attachment":{"connectionReference":{"api":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams"},"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-c9efbf63-e5a2-4102-a864-e913ec0c8ef8"},"connectionName":"shared-teams-c9efbf63-e5a2-4102-a864-e913ec0c8ef8"},"referenceKey":"shared_teams-3"},"Get_messages":{"connectionReference":{"api":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams"},"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-864099d5-54a7-4002-93b6-565ecf481128"},"connectionName":"shared-teams-864099d5-54a7-4002-93b6-565ecf481128"},"referenceKey":"shared_teams-1"},"Get_file_metadata_using_path":{"connectionReference":{"api":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-1c8b887c-61a2-4d83-ae95-966e8760de31"},"connectionName":"shared-sharepointonl-1c8b887c-61a2-4d83-ae95-966e8760de31"},"referenceKey":"shared_sharepointonline-1"},"Get_file_properties":{"connectionReference":{"api":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-15e7a58d-6555-418d-a955-a6b286a76a7b"},"connectionName":"shared-sharepointonl-15e7a58d-6555-418d-a955-a6b286a76a7b"},"referenceKey":"shared_sharepointonline-2"},"Get_file_content":{"connectionReference":{"api":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-1c8b887c-61a2-4d83-ae95-966e8760de31"},"connectionName":"shared-sharepointonl-1c8b887c-61a2-4d83-ae95-966e8760de31"},"referenceKey":"shared_sharepointonline-1"}},"staticResults":{"Send_a_Microsoft_Graph_HTTP_request":{"status":"Succeeded","outputs":{"statusCode":"OK"}}},"isScopeNode":true,"mslaNode":true}
あとがき
Adaptive Card は次回・・暑さに負けないときに、頑張る予定
関係ないけど、Teams で段落付きの画像埋め込み機能が復活したのはめでたい!!
ってもうだいぶ経ったな・・
ドキュメント
chatMessageAttachment
Attachment 詳細
チャネル:メッセージ送信
チャネル:メッセージ返信
プロパティ
チャットも出来る筈