空手道 - 如何将正文作为表单数据发送
Karate - how to send body as form data
这些是我在表单数据中的字段
uploaded_by = x@y.com
status = true
file = Excel File to be uploaded
这是我试过的代码
Given url baseUrl + uploadTemplate
And multipart field uploaded_by = <user>
And multipart field status = <status>
And multipart field file = read('Template.xlsx')
When method post
Then status 200
And match $.result == <result>
Examples:
| user | status | result |
| 'x@y.com' | true | INITIAL |
Excel 文件与功能文件所在的位置相同,我收到 500 错误,但在 POSTMAN
中运行良好
使用form field
代替multipart field
:https://github.com/intuit/karate#form-field
它适用于以下代码
Given url baseUrl + uploadTemplate
And multipart field uploaded_by = <user>
And multipart field status = <status>
And multipart field file = { read: 'Template.xlsx', filename: 'Template.xlsx', contentType: 'multipart/form-data' }
When method post
Then status 200
And match $.result == <result>
这些是我在表单数据中的字段
uploaded_by = x@y.com
status = true
file = Excel File to be uploaded
这是我试过的代码
Given url baseUrl + uploadTemplate
And multipart field uploaded_by = <user>
And multipart field status = <status>
And multipart field file = read('Template.xlsx')
When method post
Then status 200
And match $.result == <result>
Examples:
| user | status | result |
| 'x@y.com' | true | INITIAL |
Excel 文件与功能文件所在的位置相同,我收到 500 错误,但在 POSTMAN
中运行良好使用form field
代替multipart field
:https://github.com/intuit/karate#form-field
它适用于以下代码
Given url baseUrl + uploadTemplate
And multipart field uploaded_by = <user>
And multipart field status = <status>
And multipart field file = { read: 'Template.xlsx', filename: 'Template.xlsx', contentType: 'multipart/form-data' }
When method post
Then status 200
And match $.result == <result>