天天看點

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

前言

近期在項目中使用了power automate,我隻能用一個字形容,那就是“牛叉”,真的是超乎想象的好用,功能之強大讓我開始懷疑人生,哈哈,接下來通過一個執行個體看看吧

示例:在power automate中使用SharePoint rest api擷取SharePoint list資料,以及擷取資料之後對資料的操作,比如循環讀取并輸出

 步驟

一、在power automate中建立工作流

1、在浏覽器中輸入網址https://asia.flow.microsoft.com/ ,輸入O365賬号密碼

2、點選左側的【建立】,然後從右側選擇一個模闆類型,比如:自動化雲端流

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 3、輸入【流名稱】,選擇一個觸發器,根據示例的業務需求,此處選擇【建立或修改項時】,點選【建立】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 4、建立後,預設會出現一個【建立或修改項時】的步驟,根據提示,在文本框右側的下拉按鈕中選擇【站點位址】和【清單名稱】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 二、添加操作SharePoint rest api的步驟

1、添加新操作,在搜尋框中搜尋 SharePoint,在【操作】中找到【将http請求發送到SharePoint】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 2、根據要求,添加相關資訊,如下

rest api文法可以參考【SharePoint】SharePoint Rest API for Select、Filter、Sort、Paging(SharePoint rest api操作SharePoint list )

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 Uri中填寫rest api位址,其中SolutionID為動态内容,在需要引用動态值的地方點選滑鼠左鍵,可以在右側看到可用動态内容框,如下

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

3、繼續添加操作步驟【初始化變量】,用于後期擷取資料後的測試,在【内置】中找到【變量】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 然後在新視窗,選擇【初始化變量】(注意:power automate中好多操作都需要通過層級選擇)

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

設定初始化變量,填寫名稱,選擇類型等

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 4、繼續添加操作步驟【分析Json】(說明:此步驟特别重要,此步驟主要使用者對rest api擷取的結果集進行分析,分析之後可以為後期的循環操作做準備)

在【内置】中找到【資料操作】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 在子層級中選擇【分析JSON】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 【内容】選擇動态内容中的【body】(注意:一定要根據需求選擇從哪個資料源來的動态内容,此示例中根據需要選擇了上一步驟【将http請求發送到SharePoint】中的動态内容body)

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

【架構】中的内容為從SharePoint rest api接口擷取的結果集結構,注意:由于可以【從示例生成】,是以咱們先儲存該工作流,然後手動執行該工作流,在曆史記錄中點選标記執行成功的工作流

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 點選【将http請求發送到SharePoint】,複制body中的結果

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 繼續編輯【分析JSON】操作步驟,在【架構】底部點選【從示例生成】,把剛剛複制的資料結構粘貼到文本框中

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 點選【完成】後,會自動生成架構,如下圖

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

至此,通過rest api擷取資料,以及對資料的分析都完成了,下一步将一起來看看,如何使用最終的到資料結果

5、添加步驟【應用到每一個】(說明:此步驟對結果集進行循環讀取操作)

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 點選【從先前的步驟中選擇一個輸出】輸入框,在右側動态内容中,選擇【分析JSON】中的【正文】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 在【應用到每一個】中點選【添加操作】-選擇【追加到字元串變量】(說明:這一步咱們将循環出來的結果指派到變量中)

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 在【名稱】中選擇之前建立的變量,在【值】中選擇動态内容【value】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 6、添加操作步驟【編輯】(說明:将變量放入到資料操作-編輯中,把最終結果輸出)

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 在輸入中,選擇動态内容【testStr】

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 好了,儲存該工作流,手動運作一下吧

7、運作結果

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟
【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

 好了,至此,在power automate中使用 SharePoint rest api以及對擷取到的資料進行處理的介紹就完成了,感覺有點兒啰嗦哈

今天隻是說明了get請求的步驟,後期将會繼續通過執行個體說明rest api post(增加)、put(更新)、delete(删除)相關操作,下期再見

【Power Automate】在power automate中使用SharePoint rest api(Send an http request to SharePoint)擷取清單資料前言 步驟

繼續閱讀