# API Post with Rich Text under comment field

**URL:** <https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641>\
**Category:** API & Developers\
**Created:** [12 December 2023 14:10 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641 "2023-12-12T14:10:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![RZ\_T](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/rz_t/32/404_2.png) [@RZ\_T](https://forum.asana.com/u/RZ_T)\
**Post date:** [12 December 2023 14:10 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/1 "2023-12-12T14:10:05Z")

</div>

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

```auto
<?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 
?>

```

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [12 December 2023 15:08 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/2 "2023-12-12T15:08:47Z")

</div>

Hi @RZ_T,

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

> **[Rich text](https://developers.asana.com/docs/rich-text#reading-rich-text)**
>
> 📘New rich text formatsWe are actively adding new rich texts formats to various objects in Asana. This may break existing apps. New apps should be built using parsers and display logic that is forward compatible with the forthcoming rich text formats....

---

<div class="post-metadata">

**Author:** ![RZ\_T](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/rz_t/32/404_2.png) [@RZ\_T](https://forum.asana.com/u/RZ_T)\
**Post date:** [13 December 2023 01:21 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/3 "2023-12-13T01:21:09Z")

</div>

tks @Phil_Seeman we are going to analyze it!

---

<div class="post-metadata">

**Author:** ![RZ\_T](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/rz_t/32/404_2.png) [@RZ\_T](https://forum.asana.com/u/RZ_T)\
**Post date:** [13 December 2023 13:59 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/4 "2023-12-13T13:59:20Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [13 December 2023 15:08 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/5 "2023-12-13T15:08:27Z")

</div>

> [@RZ\_T](#):
>
> were unable to see any code change in order to send the API

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.

---

<div class="post-metadata">

**Author:** ![RZ\_T](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/rz_t/32/404_2.png) [@RZ\_T](https://forum.asana.com/u/RZ_T)\
**Post date:** [14 December 2023 11:33 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/6 "2023-12-14T11:33:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [14 December 2023 15:46 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/7 "2023-12-14T15:46:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:00 UTC](https://forum.asana.com/t/api-post-with-rich-text-under-comment-field/632641/8 "2025-05-30T19:00:59Z")

</div>

Closed on 30 May 2025 19:00 UTC


