我正在尝试使用空手道在特定的松弛通道上上传图像,但没有运气,我尝试了多次不同的步骤,但仍然有 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
OR
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 进行工作。
你似乎把事情搞混了,没有必要request
使用时身体multipart
。你的标题/参数看起来不一样。还基于doc here https://api.slack.com/methods/files.upload,文件上传字段的名称是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 文档的人寻求帮助。或者让 Postman 测试工作起来,然后你就会很容易地找出你错过了什么。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)