我想用HttpRequestLibrary在Robot框架中使用“Content-Type:multipart/formdata”发出POST请求,但它不适合我。在
请求的卷曲度为:
curl -X POST "https://xxx-approuter-xxx-xxxxxx" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "pkcsFile=" -F "crtFile=" -F "privateKey=" -F "jsonBody={'method' = 'BASIC_AUTH', 'username' = 'xxx', 'password' = 'xxxxx'}"
我的问题是我不知道jsonBody变量应该在哪里以及如何用robot scripr定义。它在Postman中工作正常,因为在请求的body中,我可以选择formdata,然后将key定义为jsonBody,其值为
^{pr2}$下面是我的机器人脚本示例:
${headers}= Create Dictionary Content-Type=multipart/form-data Authorization=${token}
${data}= Create Dictionary jsonBody={'method' = 'BASIC_AUTH', 'username' = 'xxx', 'password' = 'xxxxx'}
${resp}= Post Request my_session /authentications data=${data} headers=${headers}
返回错误:
"message": "Required AuthenticationDto parameter jsonBody is not present"
有人能帮我吗?或者举一个关于如何使用内容类型为multipart/formdata的HttpRequestLibrary的适当例子
经过多次尝试,我想到了这个场景,但也失败了:
结果是:
^{pr2}$我必须以某种方式提供键值jsonBody,但我不确定是否正确
如果要获取此json:
你的字典语法不正确
更改:
^{pr2}$结果是:
收件人:
结果就出来了
编辑:
如果你需要得到这根绳子
您要做的是,您正在使用
jsonBody=${var}
robot框架将把jsonBody作为字典的第一个键来创建一个嵌套字典您需要的是一个字符串,然后再进行听写。在你可以用卡塔特把绳子连在一起
结果
相关问题 更多 >
编程相关推荐