Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to fetch comments with attached documents of an issue via rest api

We have a use case where user can attach file/image in the comment section. But when we are retrieving comments for a particular issue we are not able to reference file which belongs to a particular comment and the attachments are present in other object called as attachment. the comments lies inside comment array. How can i get comments with the attached files in the comment section?

1 answer

0 votes

Hello @Ankush Sharma 

 

I just try in my dev instance this API :

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issue-issueIdOrKey-comment-get

It retrieve all comment from an issue. When you have an attachment in a comment the API should return something like this :

body": {
"version": 1,
"type": "doc",
"content": [
{
"type": "mediaGroup",
"content": [
{
"type": "media",
"attrs": {
"id": "039e7ec6-9e7a-42c1-b261-833430aa2aa9",
"type": "file",
"collection": "jira-10608-comment-10121"
}
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "hello "
}
]
}
]
},

Here what my comment looks like 

comments.png

Hope this helps 

That i know already but the problem is the files i have attached when i gets the comments via rest api then the files i have uploaded, i am getting those files in attachment response and it was very confusing which file belongs to which comment and if comment section has more than one document then there is relation between the two. 

Waiting for the reply

The API return the comment and the file that belong to it in the body. So if you have 2 comment, you will have 2 body with their attachment and string comment.

 

Hope this helps

Still the name of the attached file is missing in body of comment and it is available in attachments object then how can i get which file belongs to which comment

Hello there!

I have the same question, can anybody help?)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you