空手道:多部分文件:读取有效,但传递内容值失败 [英] Karate: Multipart file : read works but passing content in value fails

查看:10
本文介绍了空手道:多部分文件:读取有效,但传递内容值失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个端点,它有一个多部分请求,它接受两个文件作为请求参数的一部分。 我使用Read尝试了下面的代码片段,它起作用了,但我的用例是从文件中获取内容并将其传递给Value参数。 我可以将内容作为文件传递吗?

如果我尝试从目录读取文件,则工作代码为

工作功能::

Scenario:
* configure headers = {'Content-Type' : 'multipart/form-data', 'Authorization': 'Bearer sgahshshshs'}
Given url "http://filecompare.com/compare"
And multipart file oldfile = { read: './oldfile.json', filename: 'oldfile.json'}
And multipart file newfile = { read: './newfile.json', filename: newfile.json'}
When method post
Then status 200

不工作功能::

Scenario:
Given url "http://download-oldfile/oldfile"
When method get
* def oldfile = response
Given url "http://download-newfile/newfile"
When method get
* def newfile = response
* configure headers = {'Content-Type' : 'multipart/form-data', 'Authorization': 'Bearer sgahshshshs'}
Given url "http://filecompare.com/compare"
And multipart file oldfile = { value: '#(oldfile)', filename: 'oldfile.json'}
And multipart file newfile = { value: '#(newfile)', filename: newfile.json'}
When method post
Then status 200

内容打印正确,但使用Value时API返回错误

如果在运行多部分文件中的VALUE关键字时遗漏了什么,请告诉我。 谢谢您

推荐答案

只能尝试将值转换为字符串:

* string oldfile = response

如果仍然卡住,请按照以下过程操作:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

这篇关于空手道:多部分文件:读取有效,但传递内容值失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆