//native
/**
* Create Task Comment
* Add a comment to a task. `html_text` takes Asana rich text (wrapped in `<body>`) and replaces `text` when set.
*/
export async function main(
auth: RT.Asana,
task_gid: string,
text: string | undefined,
html_text: string | undefined,
is_pinned: boolean | undefined
) {
const response = await fetch(
`https://app.asana.com/api/1.0/tasks/${task_gid}/stories`,
{
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
data: {
text: html_text ? undefined : text,
html_text: html_text || undefined,
is_pinned: is_pinned || undefined,
},
}),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 3 hours ago