![](/img/trans.png)
[英]Unable to find a way to upload attachments using URL to ALM via REST API
[英]Upload attachments using clickup api
我正在尝试将附件上传到点击任务。 点击 API
Click up 确实提供了示例代码,下面是 clickup 示例代码
from urllib2 import Request, urlopen
values = """
attachment: raw_image_file (file)
filename: example.png (string)"""
headers = {
'Authorization': '\'access_token\'',
'Content-Type': 'multipart/form-data'
}
request = Request('https://private-anon-f799579c66-clickup20.apiary-mock.com/api/v2/task/{task_id}/attachment?custom_task_ids=&team_id=
', data=values, headers=headers)
response_body = urlopen(request).read()
print response_body
我用它作为参考,并为项目使用了 requests lib
这是使用请求库的代码
import requests
attachment_headers = {'Authorization': self.access_token, 'Content-Type': 'multipart/form-data'}
r = requests.post(f"https://private-anon-df9b125a00-clickup20.apiary-mock.com/api/v2/task/{task_id}/attachment",
files={"attachment": ("attachment", open("attachment.png", "rb")), "filename": "example.png"},
headers=attachment_headers)
print(r)
print(r.json())
我确实收到状态代码为 200 并且没有错误消息,但是当我检查 clickup 任务时它没有显示任何附件
我在这里先向您的帮助表示感谢!
您必须删除文件参数的“文件名”部分。
file = {"attachment": ('choose_your_name.png', open('file.png', 'rb'))}
headers = {'Authorization': config.clickup_access_token}
request = requests.post(f'https://api.clickup.com/api/v2/task/{task_id}/attachment', files=file, headers=headers)
print(request.json())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.