【发布时间】:2022-04-09 04:25:58
【问题描述】:
我正在尝试在 ROBOT 框架中传递以下 API 请求:
curl --request POST --url <API End Point> --form 'mldata={"id": “idname”, "author": “author name, "title": “title name, "description": “description details“, "version": "0.0.4", "image": “/path/to/image”, "icon": "base64 encoded image"};type=application/json' --header "Authorization: <Bearer Token>”
在 ROBOT 框架 [版本:3.2.2] 中编写相同,但得到 error: "status=400, reason=Bad Request body={"message":"Request is not a multipart request!"}"强文本
看来我没有以正确的方式传递 --form 数据。 请求帮助传递表单数据 [--form 'mldata={"id": "idname", "author": "author name, " title": "标题名称", "description": "description details", "version": "0.0.4", "image": "/path/to/image", "icon": "base64 编码图像"}; type=application/json'] 在机器人框架中。
我应该如何正确通过?
Onboard ML From External Repo
[Arguments] ${token}=default
Create Session session ${host}
${data}= Create Dictionary id=${id} author=${author} title=${title} description=${description} version=${version} image=${repo_path}
${form_data}= Evaluate {'mldata=': ${data}}
${header}= Create Dictionary Authorization=${token}
${response}= Post Request session /v1/ml data=${form_data} headers=${header}
Should Be Equal As Strings ${response.status_code} 200
【问题讨论】:
标签: robotframework