我为POST请求创建一个API自动化测试。我使用以下库:RequestLibrary和HttpLibrary.HTTP。
我有一个用于请求正文的JSON对象。我的标题包含内容类型:application/json
和API密钥。如何在机器人框架中发送api密钥?
***Settings***
Library RequestsLibrary
Library HttpLibrary.HTTP
***Variables***
${url} https://blabla/api/login
${email} blabla
${password} blabla
***Test Cases***
API Login Email
${apikey}= Set Variable wQ0f7FgE9wLhq
${body}= catenate {"email_or_phone":${email},"password":${password}}
&{header}= Create Dictionary Content-Type=application/json
CreateSession login ${url} ${header} auth=${apikey} verify=True
${resp}= Post Request login api/login data=${body} headers=${header}
Should Be Equal As Strings ${resp.status_code} 200