下面是登录脚本,最后获取token值
test
${headers} Create Dictionary Content-Type=application/json User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36
Create Session app http://texxxxxx8060
${data} Create Dictionary account=guest_Pai_shz password=123456
${get_body} POST On Session app /api/gv-op/userAuth/login headers=${headers} json=${data}
log ${get_body.json()["data"]["token"]} #获取token值
#封装关键字(登录),把ip、端口号、用户名、密码、path 进行参数设置,最后返回结果数据;
---------GET请求(查询操作)
get代码如下:
${accessToken} ${refreshToken} 获取token值
${header} Create Dictionary Content-Type=application/json User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 accessToken=${accessToken} refreshToken=${refreshToken}
Create Session app http://test.xxxxx.com:8060 ${header} #此处的${header} 也可以去掉
${rep} Get Request app /api/gv-op/otaTask/page?current=1&size=10 ${header}
log ${rep.json()}
----POST请求 (新增操作)
post代码如下:
${accessToken} ${refreshToken} 获取token值
${header} Create Dictionary Content-Type=application/json User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 accessToken=${accessToken} refreshToken=${refreshToken}
Create Session app http://test.line.meltiot.com:8060
${data} Set Variable {"configKey":"1","configValue":"2","remark":"3"}
${resp} POST On Session app /api/gv-op/sysConfig/insert data=${data} headers=${header}
log ${resp.json()}