Adding attachments to a story

Hello, I’m trying to figure out how to add an attachment to a story (comment) on a task through the API. I’m using the createAttachmentForObject method in the AttachmentsApi library (through NodeJS). I can’t figure out how to set a comment on the attachment.

Using the attached screenshot as an example. If I use the getAttachment API, I can get the image of the duck. And, if I use the getStory API, I can see the comment “This is a picture of a duck.” But, I don’t really see anything that binds one to another. So, when I actually POST a story/attachment into my Asana task through the API, I don’t see a way to set text to an attachment, or an attachment to a text comment (story). Is there a way to accomplish my use case?

Hi @Christine_Hill2,

I don’t think so. There were several threads on this overall topic; they were more in terms of getting, not posting, but I think the conclusion is that the API currently doesn’t have the ability to associate attachments with specific comments/stories, either to read or write:

cc’ing @John_Baldo @Jeff_Schneider for confrmation…

2 Likes

I have found one workaround which I was using during YouTrack - Asana migration.

  1. add attachments to Task via Upload an attachment. Retrieve its gid.
  2. add Story to that Task via Create a story on a task with html_text like
{"data":{"html_text":"<body>Imline attachment: <a data-asana-gid=\"XYZ\"/></body>"}}

where XYZ is asana attachment gid. Or, if your attachment is image, you can create inline image like that:

{"data":{"html_text":"<body>Imline image: <img data-asana-gid=\"XYZ\"></body>"}}

That is described in Rich text.

That will create neat small link:

Or inline image:

That is not the same thing you was asking for, but at least some workaround one can use while migrating from other trackers to Asana.

1 Like

That also works on Tasks - just use html_notes instead of html_text

1 Like