Power Automate で SharePoint のリストアイテムのコメントを操作(取得 / 作成 / 削除)する方法を記載します。
利用するアクション
いずれの操作(取得 / 作成 / 削除)も「SharePoint に HTTP 要求を送信します」アクションを利用します。
コメントの取得
コメントを取得する場合は、「SharePoint に HTTP 要求を送信します」アクションを次のように設定します。
※リストの GUID は、リストの設定画面の URL から確認することができます。
URI は、次の通りです。
_api/web/lists('@{variables('リストのGUID')}')/GetItemById(@{variables('アイテムID')})/Comments
正常に取得された場合、次のようなコメント情報が記載された JSON が取得できます。
{ "d": { "results": [ { "__metadata": { "id": "https://{tenant}.sharepoint.com/sites/{site}/_api/web/lists('{ListGUID}')/GetItemById(1)/Comments(20)", "uri": "https://{tenant}.sharepoint.com/sites/{site}/_api/web/lists('{ListGUID}')/GetItemById(1)/Comments(20)", "type": "Microsoft.SharePoint.Comments.comment" }, "likedBy": { "__deferred": { "uri": "https://{tenant}.sharepoint.com/sites/{site}/_api/web/lists('{ListGUID}')/GetItemById(1)/Comments(20)/likedBy" } }, "replies": { "__deferred": { "uri": "https://{tenant}.sharepoint.com/sites/{site}/_api/web/lists('{ListGUID}')/GetItemById(1)/Comments(20)/replies" } }, "author": { "__metadata": { "type": "SP.Sharing.Principal" }, "email": "test@contoso.onmicrosoft.com", "expiration": null, "id": 7, "isActive": true, "isExternal": false, "jobTitle": null, "loginName": "i:0#.f|membership|test@contoso.onmicrosoft.com", "name": "とやまてっちゃん", "principalType": 1, "userId": null, "userPrincipalName": null }, "createdDate": "2020-11-28T11:07:10.51Z", "id": "20", "isLikedByUser": false, "isReply": false, "itemId": 1, "likeCount": 0, "listId": "fb6ee5d4-bc7c-462d-8456-384879807ef4", "mentions": { "__metadata": { "type": "Collection(Microsoft.SharePoint.Comments.Client.Identity)" }, "results": [] }, "parentId": "0", "replyCount": 0, "text": "コメントテスト!!!" } ] } }
コメントの作成
コメントを作成する場合は、「SharePoint に HTTP 要求を送信します」アクションを次のように設定します。
URI は、次の通りです。
_api/web/lists('@{variables('リストのGUID')}')/GetItemById(@{variables('アイテムID')})/Comments
コメントの削除
コメントを削除する場合は、「SharePoint に HTTP 要求を送信します」アクションを次のように設定します。
URI は、次の通りです。
_api/web/lists('@{variables('リストのGUID')}')/GetItemById(@{variables('アイテムID')})/Comments(@{variables('コメントのID')})