实际事例
1.get接口实例
一段json数据,json的格式
[{ "key1": "values", "key2": "values" }, { "key1": "values", "key2": "values" } ]
代码实例
{ "description": "模拟获取某个功能的具体信息接口,get请求和响应,返回json格式数据", "request": { "method": "get", "url": "/book_info", "queries": { "bookname": "软件测试", "checkstatus": "on" } }, "response": { "json": { "error_code": 0, "reason": "successed", "name": "软件测试", "price": "666" }, "status": 200 } }
2.post接口实例
代码实例
{ "description": "模拟xx接口,post_form请求和响应,入参是form形式,返回是json数据", "request": { "headers": { "content-type": "application/x-www-form-urlencoded" }, "method": "post", "url": "/login", "forms": { "username": "zhangshan", "password": "123456" } }, "response": { "json": { "error_code": 0, "reason": "successed", "username": "zhangshan", "checkstatus": "on" }, "status": 200 } }
注意:post中
headers:请求头,根据是form还是json格式的请求来填写
from格式:"content-type": "application/x-www-form-urlencoded"
json格式:"content-type": "application/json"
请求参数格式以及数据,对应headers的content-type
form格式关键字为forms
json格式关键字为json