Hi there,
I have the code below:
public function AsanaUpload($url){
$url = 'https://app.asana.com/api/1.0/'.$url;
$rsIntegration = $this->Integration($_COOKIE["idRefSite"], 1);
$arIntegration = $rsIntegration->fetch(PDO::FETCH_OBJ);
$headers = array('Authorization: Bearer '.$arIntegration->AsanaBearer.'');
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->fields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output, true);
}//AsanaUpload
And I’m calling the function:
$filename = realpath("test.jpeg");
$erp->fields['file'] = "@".$filename . ";";
$attach = $erp->AsanaUpload('tasks/NUMBER OF THE TASK/attachments');
print_r($attach);
Error 1:
Array ( [errors] => Array ( [0] => Array ( [message] => file: File is not an object [help] => For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana ) ) )
And sometimes ERROR 2:
Array ( [errors] => Array ( [0] => Array ( [message] => file: Missing input [help] => For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana ) ) )
I just went here Build an app with Asana
My question is: what am I missing? I’d like to use only the file path without sending the file via FORM but is not working… Please let me know if you can help me with. Thanks!!