文章目录
- 一、Postman介绍和用例集创建
- 二、基本使用-案例
- 2.1 案例一
- 2.2 案例二
- 2.3 案例三
一、Postman介绍和用例集创建
简介:一款接口的调试和测试工具。开发和测试工程师都可以使用。 支持所有主流系统。
- 特点︰支持MAC、Windows和Linux
- 官网地址: https://www.getpostman.com/
- 使用方法:先建工作空间存放项目,再建用例集。
二、基本使用-案例
2.1 案例一
1、使用 postman 发送 http请求,访问 tpshop 商城的 “搜索” 接口
2、访问 tpshop 商城的 “搜索” 接口所需要的信息:
3、—— 结合 F12 浏览器开发者工具分析:
- 请求方法:GET(get方法不需要请求体) - URL:https://hmshop-test.itheima.net/Home/Goods/search.html?q=手机 - 请求头:无 - 请求体:无 - 返回数据:html网页2.2 案例二
使用 Postman 向 topshop 商城 登录接口 发送一个密码错误的 登录请求
-请求方法:post-URL:https://hmshop-test.itheima.net/index.php?m=Home&c=User&a=do_login&t=0.9100572859357936-请求头:Content-Type:application/x-www-form-urlencoded-请求体:--username:13700000001--password:12345--verify_code:8888-返回数据:{"status":-2,"msg":"密码错误!"}----实际返回结果 “验证码错误” 与业务有关。2.3 案例三
从接口文档,获取 登录接口 的 http请求,使用 Postman 发送
-请求方法:post-URL:http://ihrm2-test.itheima.net/api/sys/login-请求头:Content-Type:application/json-请求体:{"mobile":"13800000002","password":"123456"}-预期结果:{"success":true,"code":10000,"message":"操作成功!","data":"f5050a1b-7919-444c-9ec4-3c1a7286536d"}--data:值为登录成功生成的 令牌数据。该数据 会定时变化。