Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I "link" a "comment" with an "attachment"?

Carlos A_ López Ortín November 15, 2021

Hello, experts:

I was looking for several questions, but I found no answer.

I'm making a third party app, using the REST API of Jira Cloud, just to show an issue and all its information. Yes, I was able to get all the issue information, even description and attachment list, also, I was able to get the comments list from another part of the API, and also, I was able to get the attachment info from the attachment queries from the attachment API part.

But the problem is this: in the description field, both the comments and the isssue's, there is a "block" called "media", that refers to a file. That file is attached to the issue, for sure. Ok, no problem, I have info of both.

The problem is, the "media" block only has an ID field that match to the "mediaApiFileId" field on the attachment... but this field is blank in all of the issue's attachments. I don't have the ID on the "media" comment block, nor the "mediaApiFileId" in the attachment data.

 

How do I suposse to know what attachment should I show if there is no link between them? I don't care if I have to make 3 or 4 calls to the API, but I don't know WHAT CALLS should I do.

I tried using renderedFields option too, but it returns a relative path, and I get no information about the absolute http address I should call either.

2 answers

0 votes
Carlos A_ López Ortín November 18, 2021

For now, what I did was to ask for the comment to be rendered in html format. Then, using Html Agility Pack, navigate to the <img> tag and get the attachment URL path from the src attribute.

It looks like "/secure/attachment/23829/23829_image-20211027-073633.png". So, splitting the string with "/" character, I look at the second last string ("23829" in this case). That is the attachment ID.

Because I previously downloaded all the issue's attachment metadata, I only had to look for that ID in the list, and then call to Jira API to download it (I can get the preview from the attachment metadata, but not the image itself, because it needs the token in the header).

0 votes
Kristján Geir Mathiesen
Community Champion
November 15, 2021

Hi @Carlos A_ López Ortín 

I am no software engineer but I am wondering if these might help you

Issue attachments Cloud

Add an attachment (maybe the syntax can help you out)

HTH,
KGM

Carlos A_ López Ortín November 16, 2021

Sorry, but no. As I said, I already read the official doc. I was able to read issues, attachments and comments from the API, but there is no connection between them.

The "Add an attachment" don't help either, because I don't want to save, and the way you add an attachment has nothing to do the way you read them.

So still stuck at the same point.

Kristján Geir Mathiesen
Community Champion
November 16, 2021

Sorry @Carlos A_ López Ortín  that didn't help :/ 

Wish you best of luck!

KGM

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events