Post接口
${application}
set variable application/json #声明变量
${headers}
create dictionary Content-Type=
'${application}'
#创建字典
create
Session api http:
${data}
set variable {
"username"
:
"uesrname"
,
"password"
:
"password"
}
#声明变量
${api}
set variable /mapi/account/xxxx #声明变量
${addr}
Post Request api ${api} data=${data} headers=${headers} #使用指定别名中找到的会话对象发送POST请求
log
${addr.content} #打印日志
Should
Be Equal As Strings ${addr.status_code}
200
#转化为字符串类型,转化为字符串后两个对象相等则
true
${responsedata}
To Json ${addr.content} #将字典类型转换成Json
${keys}
Get Dictionary Keys ${responsedata} #获取接口返回的key,例如code/msg/data
${items}
Get Dictionary items ${responsedata} #获取接口返回的内容
${values}
Get Dictionary Values ${responsedata} #获取接口返回除key外的内容
${code}
Get From Dictionary ${responsedata} code #获取code的内容
${msg}
Get From Dictionary ${responsedata} msg #获取msg的内容
${data}
Get From Dictionary ${responsedata} data #获取data的内容
Should
Be Equal As Strings ${data} ${data
}
#判断data内容是否和预期的一直,一直则
true
Delete
All Sessions