postman传递当前时间戳实例详解
作者:管理随笔 时间:2022-01-09 17:28:34
请求动态参数(例如时间戳)
有时我们在请求接口时,需要带上当前时间戳这种动态参数,那么postman能不能自动的填充上呢。
我们可以使用postman的pre-request script
首先 我们在请求参数里使用这种方式填写value参数的值为{{var}}
然后在 pre-request script 添加js代码如下。 其中var为上一步定义的相同名字,可根据自己需要修改。
pm.environment.set('var',Math.round(new Date()/1000)+10);
添加完如下图。
查看后台请求日志,此时参数值变为秒为单位的时间戳
请求相应测试
如果要处理请求返回的数据,进行测试校验 可以使用test script,点击postman下面的Bootcamp,出现下图菜单,这里提供了好些使用教程,包括上文介绍的pre-request script.
点击Automated testing,点击二级菜单Working on test scripts的learning,按照教程一步一步操作即可。
来源:https://www.cnblogs.com/kala00k/p/11517941.html
标签:postman,时间戳
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python list转置和前后反转的例子
2022-04-26 10:39:55
![](https://img.aspxhome.com/file/2023/9/81719_0s.jpg)
Python实现用手机监控远程控制电脑的方法
2021-06-22 07:57:49
python区块链实现简版网络
2023-02-17 01:06:59
![](https://img.aspxhome.com/file/2023/1/114471_0s.png)
Python 中如何写注释
2022-07-10 21:53:11
python多进程实现文件下载传输功能
2022-06-27 02:22:41
python删除csv文件的行列
2021-04-10 20:41:08
搜索结果页(SERP)之:不要被F型浏览忽悠了
2009-09-07 12:34:00
![](https://img.aspxhome.com/file/UploadPic/20099/7/jakob-nielsen-58s.jpg)
javascript 实现子父窗体互相传值的简单实例
2023-08-09 09:52:52
再谈Python中的字符串与字符编码(推荐)
2023-06-15 23:25:08
![](https://img.aspxhome.com/file/2023/5/81445_0s.png)
关于SQL Server中索引使用及维护简介
2008-12-24 15:39:00
使用PyInstaller将Python程序文件转换为可执行程序文件
2023-03-28 11:35:34
用SQL语句完成SQL Server数据库的修复
2008-11-24 20:49:00
python编写微信远程控制电脑的程序
2023-08-15 17:04:38
![](https://img.aspxhome.com/file/2023/1/131161_0s.png)
python3.0 字典key排序
2022-06-03 15:07:50
Eclipse + Python 的安装与配置流程
2021-07-25 06:34:18
用python生成(动态彩色)二维码的方法(使用myqr库实现)
2023-05-08 16:24:05
![](https://img.aspxhome.com/file/2023/0/124150_0s.gif)
python中安装django模块的方法
2023-08-27 13:30:21
![](https://img.aspxhome.com/file/2023/1/65051_0s.png)
Golang中的sync.WaitGroup用法实例
2023-08-31 03:57:28
php的RSA加密解密算法原理与用法分析
2023-07-13 11:27:14
python getopt 参数处理小示例
2021-03-02 13:05:02