文章源自略懂百科-http://wswcn.cn/24756.html
下载和安装比较简单,就不再介绍文章源自略懂百科-http://wswcn.cn/24756.html
一、Postman的基础功能二、接口请求流程文章源自略懂百科-http://wswcn.cn/24756.html
1. GET 请求文章源自略懂百科-http://wswcn.cn/24756.html
GET请求:点击Params,输入参数及value,可输入多个,即时显示在URL链接上,文章源自略懂百科-http://wswcn.cn/24756.html
所以,GET请求的请求头与请求参数如在接口文档中无特别声明时,可以不填。文章源自略懂百科-http://wswcn.cn/24756.html
响应 示例: 这里会有请求的响应状态码,响应时间,以及响应大小文章源自略懂百科-http://wswcn.cn/24756.html
响应体示例: 响应的格式可以有多种,我这里由于请求的是 百度,so, 响应的是 html ,文章源自略懂百科-http://wswcn.cn/24756.html
一般情况下,我们自定义接口的话是 json格式的响应体文章源自略懂百科-http://wswcn.cn/24756.html
2. POST请求文章源自略懂百科-http://wswcn.cn/24756.html
POST请求一:表单提交文章源自略懂百科-http://wswcn.cn/24756.html
下图示例中设置了请求方法,请求URL,请求参数,但是没有设置请求头文章源自略懂百科-http://wswcn.cn/24756.html
在我的使用过程中,请求头是根据请求参数的形式自动生成的文章源自略懂百科-http://wswcn.cn/24756.html
请求头中的Content-Type与请求参数的格式之间是有关联关系,比如:文章源自略懂百科-http://wswcn.cn/24756.html
POST请求二:json提交文章源自略懂百科-http://wswcn.cn/24756.html
下图中,当我们选择JSON(application/json) 是会自动帮我们设置 headers 为 application/json文章源自略懂百科-http://wswcn.cn/24756.html
在这里就不截图 举例了,朋友们可以自行去查看文章源自略懂百科-http://wswcn.cn/24756.html
POST请求三:xml提交文章源自略懂百科-http://wswcn.cn/24756.html
POST请求四:二进制文件提交文章源自略懂百科-http://wswcn.cn/24756.html
其它请求方式如PUT,DELETE 大致流程和GET,POST 差不多,这里就不一一举例说明了文章源自略懂百科-http://wswcn.cn/24756.html
三、管理用例—Collections文章源自略懂百科-http://wswcn.cn/24756.html
在POST基础功能那里有一张图片大致说了一下Collections 的作用, 这里我们再详细说明一下文章源自略懂百科-http://wswcn.cn/24756.html
Collections集合:也就是将多个接口请求可以放在一起,并管理起来。什么样的接口请求可以放在同一个collection里?文章源自略懂百科-http://wswcn.cn/24756.html
在这里告诉大家可以这样:一个工程一个Collection,这样方便查找及统一处理数据。文章源自略懂百科-http://wswcn.cn/24756.html
第一步, 创建Collections文章源自略懂百科-http://wswcn.cn/24756.html
点击上图中的带+号的图标,输入Name:abc,Description:示例demo,点击Create按钮即创建成功一个Collections.文章源自略懂百科-http://wswcn.cn/24756.html
第二步,在Collections里添加请求文章源自略懂百科-http://wswcn.cn/24756.html
在右侧准备好接口请求的所有数据,并验证后,点击save按钮。文章源自略懂百科-http://wswcn.cn/24756.html
保存好之后就可以在这里看到啦,之后要再次调用时可以点击这里,方便快捷有木有文章源自略懂百科-http://wswcn.cn/24756.html
collections 管理精细化, 这里我们针对不同的请求方式做分组文章源自略懂百科-http://wswcn.cn/24756.html
添加子文件夹文章源自略懂百科-http://wswcn.cn/24756.html
这是我们精细化划分之后的结果, 是不是看着有条理多了?文章源自略懂百科-http://wswcn.cn/24756.html
四、身份验证Authentication文章源自略懂百科-http://wswcn.cn/24756.html
1、Basic Auth文章源自略懂百科-http://wswcn.cn/24756.html
是基础的验证,所以会比较简单文章源自略懂百科-http://wswcn.cn/24756.html
会直接把用户名、密码的信息放在请求的 Header 中文章源自略懂百科-http://wswcn.cn/24756.html
2、Digest Auth文章源自略懂百科-http://wswcn.cn/24756.html
要比Basic Auth复杂的多。使用当前填写的值生成authorization header。所以在生成header之前要确保设置的正确性。如果当前的header已经存在,postman会移除之前的header。文章源自略懂百科-http://wswcn.cn/24756.html
3、OAuth 1.0文章源自略懂百科-http://wswcn.cn/24756.html
postman的OAuth helper让你签署支持OAuth文章源自略懂百科-http://wswcn.cn/24756.html
1.0基于身份验证的请求。OAuth不用获取access token,你需要去API提供者获取的。OAuth 1.0可以在header或者查询参数中设置value。文章源自略懂百科-http://wswcn.cn/24756.html
4、OAuth 2.0文章源自略懂百科-http://wswcn.cn/24756.html
postman支持获得OAuth 2.0 token并添加到requests中。文章源自略懂百科-http://wswcn.cn/24756.html
作者:痴乙
原文:https://blog.csdn.net/fxbin123/article/details/80428216文章源自略懂百科-http://wswcn.cn/24756.html
文章源自略懂百科-http://wswcn.cn/24756.html
评论