postman的使用

1. 创建|导入|导出集合

创建集合

postman的使用

导入集合

postman的使用

导出集合

postman的使用

2. 集合生成API文档

生成API文档的前提

  1. 需要登录
  2. 存在集合 与 对应的请求

postman的使用

浏览器右上角点击 publish

postman的使用

3. 创建API请求

   GET | POST | DELETE | PUT 

3.1 添加请求参数

3.1.1 get请求参数

参数直接跟随 url

http://www.test.com/user/getuser?id=7
3.1.2 post请求参数

bodyform-data

postman的使用

3.1.3 文件请求参数

postman的使用

3.1.4 json请求参数
{
	"username":"zhangsan",
	"phone":"13712457889",
	"gender":25
}

postman的使用

3.1.5 xml请求参数
<?xml version="1.0" encoding="UTF-8"?>
<o>
     <gender type="number">25</gender>
     <phone type="string">13712457889</phone>
     <username type="string">zhangsan</username>
</o>

postman的使用
json转xml工具:https://www.sojson.com/json2xml/

3.2 添加请求头 header

postman的使用

3.3 添加请求 cookie

send 按钮下方有个 cookie 点击 弹出的cookie 添加

postman的使用

4. 批量运行集合

点击 集合右上角 点击 Run

postman的使用

postman的使用

这能批量运行这个集合里的所有请求接口

5. newman 命令行使用

$ npm install -g newman

批量运行集合

$ newman run mycollection.json

运行结果

postman的使用

参考文档:https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/