Hi,
I am trying to add custom fields in asana task through API using PHP, I have followed the JSON format as per the website: Build an app with Asana. I have attached my code to this post. Could someone please help me? I am not getting any error but it’s not creating task.
$api = 'xxxxxxxxxxxxxxxxx';
$url = 'https://app.asana.com/api/1.0/tasks';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Don't print the result
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // Don't verify SSL connection
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // "" ""
curl_setopt($curl, CURLOPT_USERPWD, $api);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$cust = array(
"mantis_due_date" => "2020-02-03",
"mantis_url" => "This is some text"
);
$data = array(
"data" => array(
"workspace" => "xxxxxxxxxxxxxx",
"projects" => array('xxxxxxxxxxxx'),
"custom_fields" => $cust,
"name" => "add custom field",
"notes" => "notes1",
"assignee" => "xxxxxxxxxxx",
"due_on"=> "2020-03-02"
)
);
$data = json_encode($data);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$html = curl_exec($curl);
curl_close($curl);
$html = json_decode($html);
var_dump($html);
Thank you!