I am trying to fetch task details after update through asana API. I am able to fetch all task details except custom fields. It is giving me an error like string to array conversion. Could someone please help me out?
Below is the code I am using for this:
$data = array(
"data" => array(
"workspace" => "XXXXXXXXXXXXXXXXXX",
// "projects" => array('XXXXXXXXXXXXXX'),
"name" => $row[1],
"notes" => $row[5],
"assignee" => $id,
"custom_fields" => $cust,
)
);
$data_json = json_encode($data);
$url1 = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$api = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json)));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERPWD, $api);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute curl and assign returned data
$response = curl_exec($ch);
// Close curl
curl_close($ch);
$html = json_decode($response, true);
$asana_id= $html['data']['gid'];
$assignee_gid = $html['data']['assignee']['gid'];
$assignee = $html['data']['assignee']['name'];
$description= $html['data']['notes'];
//to fecth custom_fields
echo $html['data']['custom_fields']['gid'];
I am facing issue here: echo $html[‘data’][‘custom_fields’][‘gid’];
Thank you!