Last active
April 13, 2023 13:47
-
-
Save dougblackjr/2be6c114e80223d0e7398c635b489819 to your computer and use it in GitHub Desktop.
Clickup File Attachment via API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$yourApiToken = 'your-api-token'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://api.clickup.com/api/v2/task/{task_id}/attachment?custom_task_ids=&team_id="); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_HEADER, FALSE); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
$filepath = '/path/to/file'; | |
$file = curl_file_create($filepath, 'image/png', 'filename'); | |
curl_setopt( | |
$ch, | |
CURLOPT_POSTFIELDS, | |
[ | |
'attachment' => $file, | |
] | |
); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
"Authorization: {$yourApiToken}", | |
"Content-Type: multipart/form-data" | |
)); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
var_dump($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you
at least I have it working with curl right now
but maybe someone made it working with GuzzleHttp?
I am using:
and i tried fopen() and file_get_content() for 'contents'
but it always:
'{"err":"No attachment supplied","ECODE":"ATTCH_039"}'
I am using Guzzle for all other requests
so, please, let me know with an example