zoukankan      html  css  js  c++  java
  • postman全局变量和环境变量

    1.在上一个接口的Tests断言中通过JSON取值

    //通过JSON提取

    var jsData = JSON.parse(responseBody)

    pm.globals.set("new_token",jsData.access_token);

     

    //通过正则表达式提取

    var access_token = responseBody.match(new RegExp('"access_token":"(.+?)"'))[1]

    pm.globals.set("new_token",access_token);

     

    2.在下一个接口通过{{new_token}}获取全局变量。

     

     

    多层嵌套时取值的方法

    {

    "tags": [

    {

    "id": 2,

    "name": "星标组",

    "count": 0

    },

    var jsData = JSON.parse(responseBody)

    pm.globals.set("new_token",jsData.tags[0].id);

     

    {{$timestamp}} 服务器的时间戳

    {{$randomInt}} 随机出0-1000的随机数

    {{$guid}} 随机出一个字符串

     

    Postman:专为接口而生

    newman:专为postman而生,执行非GUI方式

     

    newman run "e:yongli.json" -e "e:\huanjing.json" -g "e:quanju.json" -r cli,html,json,junit --reporter-html-export "e: esult.html"

     

    接口签名:sign

    csrf_token:鉴权码

    sign = MD5(appkey+参数名+时间戳)

  • 相关阅读:
    js操作class值
    四、多表连接
    三、约束
    根据出生日期计算年龄
    二、MySql数据操作(二)
    一、MySql基本语句(一)
    jquery基本操作
    纯js实现全选,全不选,反选
    css的基础知识1
    表格的使用
  • 原文地址:https://www.cnblogs.com/wangfan9/p/13468409.html
Copyright © 2011-2022 走看看