Hi everyone.
I am doing some API work right now and I am creating tasks and subtasks.
Now I need to add attachments from my form into the task.
$binary = file_get_contents($_FILES['file']['tmp_name'][$i]);
$fileName = $_FILES['file']['name'][$i];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://app.asana.com/api/1.0/tasks/' . $taskGid . '/attachments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file' => $binary, 'resource_subtype' => 'asana', name => $fileName),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer $token',
'Cookie: TooBusyRedirectCount=0; TooBusyRedirectCount=0; logged_out_uuid=54a01a0dd7857620640436eb9ab6e4e0' ),
));
$resp = curl_exec($curl);
This is what I have right now.
It does not upload the file at all as an attachment.
I have been looking through this forum, google and everything I could find, but I can’t find a solution that works here.