Power Automate: Yammer API も Send an HTTP request to SharePoint で動きますね

# 背景
Yammer の過去メッセージをみたいという話があったが、Power Automate のカスタムコネクターは会社では使えない。

それなら Power BI のカスタムコネクターで NaviTable を使って上手く作れないかな？と思いつく。
その前に取得確認をしようとしたら Power Automate 昔の記憶と違って、普通に使えたので、一応記録

https://qiita.com/baku2san/items/818887dc899c1891bf16

# 概要

- [HTTP 要求を送信する (プレビュー)](https://docs.microsoft.com/ja-jp/connectors/office365groups/#http-%E8%A6%81%E6%B1%82%E3%82%92%E9%80%81%E4%BF%A1%E3%81%99%E3%82%8B-(%E3%83%97%E3%83%AC%E3%83%93%E3%83%A5%E3%83%BC)) ではダメ
- [HTTP リクエストを SharePoint に送信します](https://docs.microsoft.com/ja-jp/connectors/sharepointonline/#http-%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E3%82%92-sharepoint-%E3%81%AB%E9%80%81%E4%BF%A1%E3%81%97%E3%81%BE%E3%81%99) なら、普通に使えます

https://developer.yammer.com/docs/messagesin_groupgroup_id

# ポイント
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/5c2ae9f0-9c16-e594-6568-6fb0e0e03027.png)

```url:SiteAddress
https://www.yammer.com/
```
```url:Uri例
api/v1/messages/in_group/eyJfdHlwZSI6Ikdyb3VwIiwiaWQiOiI0MjE3MzkwNjk0NCJ9.json?older_than=@{variables('NewerId')}
```

# 利用例
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/03d4c5df-cb9f-0c27-c9ac-8b2035bd9ed8.png)

## 実装例
```json:上記画像のScope内
{"id":"2493c264-78b2-4dd2-9b72-adf8-279e7639","brandColor":"#8C3900","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-1c8b887c-61a2-4d83-ae95-966e8760de31"}},"shared_office365groups":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365groups/connections/5e96053ddc264f998e74dbe3ccf3ef9c"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope","operationDefinition":{"type":"Scope","actions":{"Do_until":{"type":"Until","expression":"@equals(false, '')","limit":{"count":10,"timeout":"PT1H"},"actions":{"Send_an_HTTP_request_to_SharePoint":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"HttpRequest","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://www.yammer.com/","parameters/method":"GET","parameters/uri":"api/v1/messages/in_group/eyJfdHlwZSI6Ikdyb3VwIiwiaWQiOiI0MjE3MzkwNjk0NCJ9.json?older_than=@{variables('NewerId')}"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{}},"Parse_JSON":{"type":"ParseJson","inputs":{"content":"@body('Send_an_HTTP_request_to_SharePoint')","schema":{"type":"object","properties":{"threaded_extended":{"type":"object","properties":{}},"messages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"sender_id":{"type":"integer"},"delegate_id":{},"replied_to_id":{},"created_at":{"type":"string"},"network_id":{"type":"integer"},"message_type":{"type":"string"},"sender_type":{"type":"string"},"url":{"type":"string"},"web_url":{"type":"string"},"group_id":{"type":"integer"},"body":{"type":"object","properties":{"urls":{"type":"array","items":{"type":"string"}},"parsed":{"type":"string"},"plain":{"type":"string"},"rich":{"type":"string"}}},"thread_id":{"type":"integer"},"client_type":{"type":"string"},"client_url":{"type":"string"},"system_message":{"type":"boolean"},"direct_message":{"type":"boolean"},"chat_client_sequence":{},"language":{"type":"string"},"notified_user_ids":{"type":"array"},"privacy":{"type":"string"},"attachments":{"type":"array"},"liked_by":{"type":"object","properties":{"count":{"type":"integer"},"names":{"type":"array"}}},"content_excerpt":{"type":"string"},"group_created_id":{"type":"integer"}},"required":["id","sender_id","delegate_id","replied_to_id","created_at","network_id","message_type","sender_type","url","web_url","group_id","body","thread_id","client_type","client_url","system_message","direct_message","chat_client_sequence","language","notified_user_ids","privacy","attachments","liked_by","content_excerpt","group_created_id"]}},"references":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"integer"},"name":{"type":"string"},"state":{"type":"string"},"full_name":{"type":"string"},"job_title":{"type":"string"},"network_id":{"type":"integer"},"mugshot_url":{"type":"string"},"mugshot_redirect_url":{"type":"string"},"mugshot_url_template":{"type":"string"},"mugshot_redirect_url_template":{"type":"string"},"url":{"type":"string"},"web_url":{"type":"string"},"activated_at":{"type":"string"},"auto_activated":{"type":"boolean"},"stats":{"type":"object","properties":{"following":{"type":"integer"},"followers":{"type":"integer"},"updates":{"type":"integer"}}},"email":{"type":"string"},"aad_guest":{"type":"boolean"},"thread_starter_id":{"type":"integer"},"group_id":{"type":"integer"},"topics":{"type":"array"},"privacy":{"type":"string"},"announcement":{"type":"boolean"},"direct_message":{"type":"boolean"},"has_attachments":{"type":"boolean"},"reply_disabled":{"type":"boolean"},"invited_user_ids":{"type":"array"},"read_only":{"type":"boolean"},"description":{"type":"string"},"mugshot_id":{},"show_in_directory":{"type":"string"},"created_at":{"type":"string"},"members":{"type":"integer"},"aad_guests":{"type":"integer"},"color":{"type":"string"},"external":{"type":"boolean"},"moderated":{"type":"boolean"},"header_image_url":{"type":"string"},"category":{"type":"string"},"default_thread_starter_type":{"type":"string"},"restricted_posting":{"type":"boolean"},"company_group":{"type":"boolean"}},"required":["type","id","network_id","url","web_url"]}},"external_references":{"type":"array"},"meta":{"type":"object","properties":{"older_available":{"type":"boolean"},"requested_poll_interval":{"type":"integer"},"realtime":{"type":"object","properties":{"uri":{"type":"string"},"authentication_token":{"type":"string"},"channel_id":{"type":"string"}}},"last_seen_message_id":{},"current_user_id":{"type":"integer"},"followed_references":{"type":"array"},"ymodules":{"type":"array"},"newest_message_details":{},"feed_name":{"type":"string"},"feed_desc":{"type":"string"},"direct_from_body":{"type":"boolean"}}}}}},"runAfter":{"Send_an_HTTP_request_to_SharePoint":["Succeeded"]}},"Apply_to_each":{"type":"Foreach","foreach":"@body('Parse_JSON')?['messages']","actions":{"Append_to_array_variable_IDs":{"type":"AppendToArrayVariable","inputs":{"name":"IDs","value":"@items('Apply_to_each')?['id']"},"runAfter":{}}},"runAfter":{"Parse_JSON":["Succeeded"]}},"Set_variable":{"type":"SetVariable","inputs":{"name":"OldestId","value":"@{min(variables('IDs'))}"},"runAfter":{"Apply_to_each":["Succeeded"]}},"Select":{"type":"Select","inputs":{"from":"@body('Parse_JSON')?['messages']","select":{"Message":"@item()?['content_excerpt']"}},"runAfter":{"Set_variable":["Succeeded"]}},"Apply_to_each_2":{"type":"Foreach","foreach":"@body('Select')","actions":{"Append_to_array_variable":{"type":"AppendToArrayVariable","inputs":{"name":"Messages","value":"@items('Apply_to_each_2')"},"runAfter":{}}},"runAfter":{"Select":["Succeeded"]}}},"runAfter":{}}},"runAfter":{"Initialize_variable_IDs":["Succeeded"]}}}
```

# あとがき
とはいえ、期間指定とかで取得する Query Params がないと面倒ですね・・どうしたものか・・
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/a838ac13-1c0d-796e-c437-de2a9679cdb4.png)