繁体   English   中英

使用Karate REST API工具上传文件

[英]Uploading files using Karate REST API tool

我正在尝试使用空手道在特定的松弛频道上载图片,但是没有运气,我尝试了不同的步骤多次,但是仍然有200个响应,并且该图片未显示在频道中。 尝试发布文字内容,并成功在频道上找到文字。

贝娄是我根据空手道文档进行的2次尝试:

@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可以工作。

您似乎正在混淆,使用multipart时不需要request正文。 您的标题/参数看起来不对。 同样基于此处文档 ,文件上载字段的名称为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

如果这不起作用,请可以理解如何解释Slack API文档的人员的帮助。 或进行邮递员测试,然后您将轻松找出错过的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM