ApiPost如何验证返回数据中是否包含某关键字/字符串?使用ApiPost的测试校验(断言)可以很方便的实现这个目标。
看本文前,建议先读以下apipost官方的文档:https://doc.apipost.cn/839e6acdc7341451 (ApiPost如何使用测试校验(断言))
实现
假如我们的返回结果是如下结构:
{
“errcode”: 0,
“errstr”: “success”,
“post”: {
“url”: “https://myywt.ar/kzzc”
},
“get”: [],
“request”: {
“url”: “https://myywt.ar/kzzc”
},
“put”: “url=https%3A%2F%2Fmyywt.ar%2Fkzzc”,
“header”: {
“Host”: “echo.apipost.cn”,
“Connection”: “keep-alive”,
“Content-Length”: “33”,
“Accept”: “application/json, text/javascript, /; q=0.01”,
“Accept-Encoding”: “gzip, deflate, br”,
“Accept-Language”: “zh-CN”,
“Content-Type”: “application/x-www-form-urlencoded;charset=UTF-8”,
“Cookie”: “PHPSESSID=6bvaf84un0c7j24bksm0htsiob”,
“Origin”: “https://echo.apipost.cn”