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 !!
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
Hi Stephen,
Thanks a lot for your reply !!
Is there a way to retrieve the same information using the Python APIs ?
Regards,
Herbert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.