API Post with Rich Text under comment field

hello all,
I would like to check if people here on the forum can help us, we are trying to use the API to send Rich_text as bold, mention, italic… but we are not succeeding, below is the code we are using. We check several postings but none were so specific.

below code we are using

<?php 
require_once('asana_task/asana.php');

$taskName = "XXXXX";
$tagName = "XXXXX";
$dueDate = "XXXXX";
$file = "XXXXX";
$imgName = "XXXX";
$wMsg = '<body>this is <b><i>testing</i></b></body>';
	
$asanaToken = "XXXXXXXXXXXXX";

$workspaceId = 'XXXXXXX'; // The workspace where we want to create our task
$projectId = 'XXXXXXXX'; // The project where we want to save our task

$assigneeID = 'XXXXXXXXXXX'; // [Carlos Eduardo]
$result = $asana->createTask(array(
	'workspace' => $workspaceId, // Workspace ID
	'name'      => $taskName, // Name of task
	'notes'     => $taskName.' Created via Portal', // Notes
	'tags'		=> $tagName, 
	'due_on'    => $dueDate,
	'assignee'  => $assigneeID,
	'followers' => array('XXXXXXXXX','XXXXXXXXX','XXXXXXXXX'), 
));


// As Asana API documentation says, when a task is created, 201 response code is sent back so...
if ($asana->hasError()) {
	echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
	return;
}

$taskId = $asana->getData()->gid; // Here we have the id of the task that have been created

// Now we do another request to add the task to a project
$asana->addProjectToTask($taskId, $projectId);

$file_data = array('file'=>$file,'finalFilename'=>$imgName,'mimeType'=>'image/jpeg');
$asana->addAttachmentToTask($taskId,$file_data);

$asana->commentOnTask($taskId,array('html_text' => $wMsg)); //post message

if ($asana->hasError()) {
	echo '<font color="#FF0000">Error occurred: '.$asana->responseCode.'. Error while posting data on ASANA.</font>'; //Error while assigning project to task:
	exit;
} else {
	echo 'Success';
	exit;
}
### END : Post on Asana 
?>

Hi @RZ_T,

You’re not using the correct HTML tags. See the API docs for the correct tags:

tks @Phil_Seeman we are going to analyze it!

1 Like

@Phil_Seeman tks again

we want to pass rich text to comment and not description and for that we are using following approach(code snippet above) but comment is not being posted.

$asana->commentOnTask($taskId,array(‘html_text’ => “This is testing”));

We read the document you suggested and were unable to see any code change in order to send the API in the comment field

Your sample code above uses the <b> and <i> HTML tags which are not supported by Asana and will cause any write to fail. You need to use <strong> and <em> as shown in the docs.

hi @Phil_Seeman tks again for helping us, we used like below, with strong tag

$asana->commentOnTask($taskId,array('html_text' => "<body>This is <strong>testing</strong></body>"));

but still now working

You should be getting back an error message; what is the exact text of that error return?