Forums

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

Can't retrieve the whole comment for a JIRA issue using Python API

Herbert Schmidmeier January 14, 2019

I'm trying to retrieve a particular comment using its "comment id" but it returns only the comment id. 

I can obtain the comment IDs as per the output below.

print('Comments:          ', issues.fields.comment.comments)

Comments:           [<JIRA Comment: id='475946'>, <JIRA Comment: id='475947'>, <JIRA Comment: id='475948'>, <JIRA Comment: id='475949'>, <JIRA Comment: id='475950'>, <JIRA Comment: id='475951'>, <JIRA Comment: id='475952'>, <JIRA Comment: id='475953'>, <JIRA Comment: id='475954'>, <JIRA Comment: id='475955'>, <JIRA Comment: id='475956'>, <JIRA Comment: id='475957'>, <JIRA Comment: id='475958'>]

comment = jc.comment(bug, issues.fields.comment.comments[12])
print(comment)

Comment: 475958

How do I retrieve the whole comment ? There are multiple fields in a comment like Author, date, branch, etc.

Thanks !!

 

 

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 15, 2019

Hello Herbert and welcome to the Community!

The API endpoint you’re using will respond with the values of the entire issue. When you make a call, as per your example, it will only return the value of the comment ID as requested.

You’re going to want to use the endpoint to GET Comment and from there return the values of the comment. “GET /rest/api/3/issue/{issueIdOrKey}/comment/{id}”

The example python for this request would look similar to:

# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
import json

url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/comment/{id}"

headers = {
   "Accept": "application/json",
   "Bearer": ""
}

response = requests.request(
   "GET",
   url,
   headers=headers
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

From this, when you get your response, you should be able to view the contents of the comment you requested by ID.

Please let us know if this helped with getting a response of the comment.

Regards,
Stephen Sifers

Herbert Schmidmeier January 15, 2019

Hi Stephen,

Thanks a lot for your reply !! 

Is there a way to retrieve the same information using the Python APIs ?

Regards,

Herbert

Herbert Schmidmeier January 16, 2019

Stephen,

It worked. Thanks for your help.

Regards

Herbert

Like Stephen Sifers likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events