I’m experiencing an issue with inline attachments in task descriptions when using the Asana API to update a task with an image in the html_notes
field.
Here’s a sample cURL command that demonstrates the problem:
![image|690x313](upload://oUwVX95XJakNgj9IFLz6o06oRn5.png)
curl --request PUT \
--url 'https://app.asana.com/api/1.0/tasks/1208019255764455?opt_fields=html_notes' \
--header 'accept: application/json' \
--header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'content-type: application/json' \
--data '
{
"data": {
"html_notes": "<body><img data-asana-gid="1208016509702545" src="https://app.asana.com/app/asana/-/get_asset?asset_id=1208016509702545" data-src-width="1000" data-src-height="800" data-thumbnail-url="https://app.asana.com/app/asana/-/get_asset?asset_id=1208016509702545" data-thumbnail-width="200" data-thumbnail-height="160" data-asana-type="attachment" alt="title of the image" style="width:200px;height:160px;"></body>"
}
}
'
Hi @Muhsin_P!
You’ll want to use the view_url
property from the get attachment API for the inline image. The following replicates the HTML the UI produces when creating an inline image in the html_notes
property. Of course, you’ll need to replace the {}
placeholders with your own values.
<img src="{ attachment.view_url }"
alt="{ attachment.name }"
data-asana-gid="{ attachment.gid }"
data-src-width="{ width }"
data-src-height="{ height }"
data-thumbnail-height="{ thumbnail-height }"
data-thumbnail-width="{ thumbnail-width }"
style="display:block;max-width:100%;margin-left:auto;margin-right:auto" />
Hope this helps!