天天看点

【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)获取列表数据前言 步骤

继续阅读