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’”
}
]