然后在取到uid 的值 postman.setGlobalVariable("uid", jsonData.data.user.id); //获取jwt postma...
pm.collectionVariables.set("variable_key","variable_value"); pm.environment.unset("variable_key"); pm.globals.unset("variable_key"); pm.collectionVariables.unset("variable_key"); pm.sendRequest("https://postman-echo.com/get",function(err, response) {console.log(response.json()); }); 不...
pm.globals.set("token", jsdata.data.token); JavaScript 第二种方式:正则表达式提取器 //打印响应信息 console.log(responseBody); //正则表达式提取器,match匹配,new RegExp():新建正则表达式 var data = responseBody.match(new RegExp('"token":"(.*?)"')); // 取值,并设置为全局变量 pm.globals....
Tests `pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Your test name", function () { var jsonData = pm.response.json(); console.log(jsonData.name); pm.expect(jsonData.name).to.eql("oschina是最好的开源网站之一"); });` 这里我们只...
"response": { "id": "2a26af66-ad21-42d2-8b7a-b89cd7339a47", "status": "Created", "code": 201, "header": [ { "key": "Date", "value": "Fri, 24 Nov 2023 05:43:16 GMT" }, { "key": "Server", "value": "Apache" }, { "key": "Set-Cookie", "value": "zentaosi...
Postman 对于返回的 Response 数据,支持三种显示模式。 默认格式化后的 Pretty 模式Raw 原始模式 点击Raw,可以查看到返回的没有格式化之前的原始数据:Preview 预览模式 以及Preview,是对应 Raw 原始格式的预览模式:Preview 这种模式的显示效果,好像是对于返回的是 html 页面这类,才比较有效果。
Postman 把response的值自动放到变量里,@1里面定义个变量23这里加上postman.setEnvironmentVariable("MatchID",JSON.parse(responseBody));这样reponsebody的这个值就会放到变量MatchID里面了@其他地方就可以引用了
Get a variable (获取一个变量) 该函数在全局变量和活动环境中搜索变量。 pm.variables.get("variable_key"); Check if response body contains a string (检查响应主体是否包含字符串) pm.test("Body matches string", function () { pm.expect(pm.response.text()).to.include("string_you_want_to_search...
l 功能区: Request 请求设置,查看 Response 响应结果和测试结果,可以将请求保存到收藏夹。 l 设置区:设置和管理环境变量和全局变量。 二:工具应用 1. 新建接口 1.1 创建Collection集合 在刚开始一个项目时,为了后续便于组织和管理,把同属该项目的多个 API,放在一组里。所以要先去新建一个 Collection: New -> ...
Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.