Error while getting updated issues in json fromat using python API?

Akiti Bala March 15, 2021

hi 

i have python script polling jira for every 5 min .
updated_issues = jira.search_issues(f' project = {jira_project_key} and updated >= "-12h" ',json_result=True)       

  issues = updated_issues["issues"]
        for item in issues:        

              try:                                                jissue = JIRA_Issue.objects.get(jira_key=item['key'])         

   except JIRA_Issue.DoesNotExist:                

   continue          

  desc=''                  

if jissue.finding is not None:                     

jissue.finding.severity = item['fields']['customfield_10605']['value']                    desc = item['fields']['description']

 

 

i am getting this error

Traceback (most recent call last):


File "/usr/local/lib/python3.6/site-packages/jira/resources.py", line 161, in __getattr__


return self[item]

TypeError

'CustomFieldOption' object is not subscriptable


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/jira/resources.py", line 161, in __getattr__


[2021-03-16 06:09:03,360: WARNING/MainProcess] return self[item]


TypeError

 

1 answer

0 votes
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2021

Hi @Akiti Bala ,

welcome to the Atlassian Community!

I'm not a python specialist, but after the quick check of your code, this line is suspicious for me:

jissue.finding.severity = item['fields']['customfield_10605']'value']

I believe it should be:

jissue.finding.severity = item['fields']['customfield_10605']['value']

(missing bracket) 

Akiti Bala March 16, 2021

hi Hana,

i didnt notice it . i updated post 

Thanks .

Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2021

@Akiti Bala 

to be honest, it is complicated to understand, what you are trying to achieve.

Which line has number 161?

Which type has your customfield_10605? Select List (single choice)?

Could you please paste here the whole code?

Thank you.

Akiti Bala March 16, 2021

HI @Hana Kučerová ,

The line 161 is in jira python client :

File "/usr/local/lib/python3.6/site-packages/jira/resources.py", line 161, in __getattr_

 

the custom_field_10605 is Severity choice .It may be High,Low,Medium,Info.
when i am trying to get custom field for updating local DB, it throws error .
Thanks

Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 17, 2021

I think this line

jissue.finding.severity = item['fields']['customfield_10605']['value']  

is causing the error: 'CustomFieldOption' object is not subscriptable

CustomFieldOption object is something, which is returned, when you get value from 

Select List (single choice) custom field.

Hopefully this article will help you to fix it.

Suggest an answer

Log in or Sign up to answer