1

I am trying to export all comments in excel from issues of a Jira project using python. I have used following

Comments_list.append(issue.fields.comment.comments)

for comment  in Comments_list:
    ws.cell(row=comments_row, column=comments_column).value = comment.body
    comments_row += 1

However, I am getting error ''

AttributeError: 'PropertyHolder' object has no attribute 'comment'

How can I solve this error?

Abu Shoeb
  • 4,747
  • 2
  • 40
  • 45
OliAK
  • 73
  • 8

2 Answers2

0

I don't think comments are listed like that. Looking at the return from a single story in the screenshot: enter image description here

In strict Json it would be issue["fields"]["comment"]["comments"][0]["body"]["content"][0]["content"][0]["text]

If you know your data set and can guarantee all comments will be single line text comments with no Bold, Italic, emojis, tags or anything except standard text you could get away with scanning in this way.

I did some work on getting these things in this repo - https://github.com/dren79/JiraScripting_public if it's any help. Or if you want to know how comment and description bodies are built, they are outlined here - https://developer.atlassian.com/cloud/jira/platform/apis/document/playground/

Dren79
  • 89
  • 6
0

You need to use raw to get all comments. Here you go:

Comments_list.append(issue.raw['fields']['comment']['comments'])

Here's the code snippet if you want to save all comments of a JIRA issue to an excel file:

import pandas as pd
from jira import JIRA

jira = JIRA('https://jira.atlassian.com', basic_auth = ('your-email', 'your-api-token))
my_issue = jira.issue('JRA-1234')
comments_list = my_issue.raw['fields']['comment']['comments']
comments = [x['body'] for x in comments_list]
df = pd.DataFrame(data={'Comments': comments})
df.to_excel('file-name.xlsx')

Please check out this jira-python Documentation for additional information.

Abu Shoeb
  • 4,747
  • 2
  • 40
  • 45