Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用空手道RESTAPI工具上传文件_Rest_Cucumber Jvm_Karate - Fatal编程技术网

使用空手道RESTAPI工具上传文件

使用空手道RESTAPI工具上传文件,rest,cucumber-jvm,karate,Rest,Cucumber Jvm,Karate,我正在尝试使用空手道在特定的slack频道上传图像,但运气不好,我尝试了多次不同的步骤,但仍然有200个响应,并且图像没有显示在频道中。 尝试发布文本内容,并在频道上成功找到文本 下面是我在空手道文档之后的两次尝试: @post Feature: Post images Background: * url 'https://slack.com/api/files.upload' * def req_params= {token: 'xxxxxxx',channels:'team',filen

我正在尝试使用空手道在特定的slack频道上传图像,但运气不好,我尝试了多次不同的步骤,但仍然有200个响应,并且图像没有显示在频道中。 尝试发布文本内容,并在频道上成功找到文本

下面是我在空手道文档之后的两次尝试:

@post
Feature: Post images

Background: 
* url 'https://slack.com/api/files.upload'
* def req_params= {token: 'xxxxxxx',channels:'team',filename:'from Karate',pretty:'1'}

Scenario: upload image
Given path 'api','files'
And params req_headers
And multipart file myFile = { read: 'thumb.jpg', filename: 
'upload-name.jpg', contentType: 'image/jpg' }
And multipart field message = 'image upload test'
And request req_headers
When method post
Then status 200

Given path 'files','binary'
And param req_params
And request read('thumb.jpg')
When method post
Then status 200
我错过什么了吗?尝试了在空手道演示GitHub存储库中找到的上传pdf和jpg的相同示例,但没有成功


注意:使用Slack API UI工作。

您似乎把事情搞混了,当您使用
多部分
时,不需要
请求
正文。你的标题/参数看起来不对劲。同样基于,文件上载字段的名称为
file
。试试这个:

Scenario: upload image
Given url 'https://slack.com/api/files.upload'
And multipart file file = { read: 'thumb.jpg', filename: 
'upload-name.jpg', contentType: 'image/jpg' }
And multipart field token = 'xxxx-xxxxxxxxx-xxxx'
When method post
Then status 200

如果这不起作用,请寻求能够理解如何解释SlackAPI文档的人的帮助。或者进行邮递员测试,这样你就可以很容易地找出你错过了什么。

在上面尝试过,但没有成功。使用bellow curl命令工作:curl-F file=@C:/Users/xxx/image.jpg-F channels=team-F token=xoxp-xxxxxx,使用邮递员工作,但使用空手道(表单字段…)不适用于我。好的,您有足够的信息更改空手道测试。确保您知道表单字段和多部分字段之间的区别。我不太明白curl-F的意思。祝你一切顺利:)谢谢彼得。供参考-f-->-表格