Hello,
I am attempting to create an integration of our application (Castofly) with Asana. The goal is to create a task in Asana from our application using the post task API and include HTML content in the description of the task. Although, I am getting an error when trying to include inline images. Here is what I am doing:
-
Posting a task to Asana
const data = {
name: title,
projects: [project],
workspace: workspace,
assignee: assignee,
};const published_task_response = await requestWithRetry({
method: âpostâ,
url: ASANA_TASK_URL,
mode: âcorsâ,
headers: {
âAcceptâ: âapplication/jsonâ,
âContent-Typeâ: âapplication/jsonâ,
âAuthorizationâ:Bearer ${token}
,
},
data: { data },
}); -
Uploading images as attachments to the Asana task.
const data = {
resource_subtype: âexternalâ,
parent: project_gid,
url: imgUrl,
name: castofly_image_attachment_${index + 1}
,
};
const upload_attachment_response = await requestWithRetry({
url: ASANA_ATTACHMENTS_URL,
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
},
data: { data },
});
-
After uploading the attachments, I also verify that the attachment has been successfully uploaded to Asana.
-
After that, I run an update task to include the attachments as inline images:
const update_task_response = await requestWithRetry({
url:${ASANA_TASK_URL}/${task_gid}
,
method: âputâ,
mode: âcorsâ,
headers: {
âAuthorizationâ:Bearer ${token}
,
âContent-Typeâ: âapplication/jsonâ,
},
data: { data: { html_notes: body } },
});
Here is an example of what body is for html_notes:
test for asana
1. Exploring Folder Contents
Open the folder to view its contents and manage your files.- After running the update task API, I get this error: errors: [
{
error: âreasoned_xml_parsing_errorâ,
message: âXML is invalid: Not a valid image asset id: â1208868781493200ââ
}
]