Forums

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

How do I get the latest comment via REST API call

Snehangshu Sarkar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 21, 2019

Hi Everyone,

 

I've been working on a project where I want to fetch the latest comment(if any) from Jira issue and update it in our tool. Now, when I am using the below endpoint, I am getting all comments which are unnecessary for me. 

 

https://jira.dev.corp.adobe.com/rest/api/2/search?jql=issue=AMSAUTO-10517&fields=comment

Response - 

"key": "AMSAUTO-10517",
"fields": {
"comment": {
"comments": [
{
"self": "https://jira.dev.corp.adobe.com/rest/api/2/issue/5187946/comment/16530402",
"id": "16530402",

 

One observation - I could see that I can get the comment by using "fields=comment" in the jql search, so, is there any way to grab the comments under comment?

 

Please look into it and help me with this.

 

Regards,

Snehangshu Sarkar

1 answer

1 vote
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2019

Hello,

You need to go through all comments in the comments array ("comments": [.....])  and find the latest one.

Snehangshu Sarkar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 21, 2019

Hi Alexey,

 

Thanks for the update.

Is there any way to get the latest comment only via REST API or grab the comments under comment in endpoint? Because If I am able to grab the comments, then I can use StartAt=maxResults to get only the latest one.

 

Regards,

Snehangshu Sarkar

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2019

There is no special rest api for getting the latest comment. You need to iterate over all comments and find the latest one.

Like # people like this
Eric López
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 24, 2020

You can order the result from the latest and ask to return the first

something like

 

https://YOURSITE.atlassian.net/rest/api/3/issue/ISSUEID/comment?orderBy=-created&maxResults=0&expand=renderedBody

Like # people like this

Suggest an answer

Log in or Sign up to answer