user2110655
user2110655

Reputation:

JIRA API error when trying to pull details when field is empty

I am using the JIRA API to pull ticket details and put it in a separate database that I can connect Tableau to. My problem is that when pulling in a ticket details (using python) where e.g. it has no priority, that I get an error. How do I get around that error? How can I handle this error?

Just currently testing by printing the details on-screen:

for issue in issues:
if verbose:
            print( "issue.key: ", issue.key );
            print( "issue.fields.project.id: ", issue.fields.project.id );

The error I get is:

cursor.execute(sql_stmt, (issue.key, issue.fields.issuetype.name, issue.fields.project.name, issue.fields.summary, issue.fields.updated,issue.fields.priority.name)) AttributeError: type object 'PropertyHolder' has no attribute 'priority

Upvotes: 1

Views: 3176

Answers (2)

user2110655
user2110655

Reputation:

Thanks @Karimtabet. It seems though that the following worked better:

if verbose:
    try:
        print( "issue.key: ", issue.key );
        print( "issue.fields.project.id: ", issue.fields.project.id );
    except AttributeError:
        key = None

Upvotes: 0

Karim Tabet
Karim Tabet

Reputation: 1847

Catch the AttributeError

for issue in issues:
    if verbose:
        try:
            print( "issue.key: ", issue.key );
            print( "issue.fields.project.id: ", issue.fields.project.id );
        except AttributeError:
            pass

Upvotes: 1

Related Questions