空手道DSL:如何将特定的键和值(XML)作为x-www-form-urlencode添加到请求正文中?



我正在尝试通过空手道将特定的键,值添加到请求正文中,作为x-www-form-urlencode。

示例中的最后一个"和请求"失败。

通过邮递员,我创建了一个工作示例,它为我们提供了正确的响应。(导出下面的主要部分(

"item": [
{
"name": "http://www.google.com/api",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "our_xml",
"value": "<create_stuff> .... XML .... </create_stuff>",
"type": "text"

Scenario: XXX
Given url 'http://www.google.com/api'
And header Content-Type = 'application/x-www-form-urlencoded'
And request{"our_xml" : read('classpath:xml/post.xml')

我想你错过了form field的存在:https://github.com/intuit/karate#form-field - 标题将自动设置。

* form field key = 'our_xml'
* form field value = read('classpath:xml/post.xml')

相关内容

最新更新