Hi All While pulling jira data i am getting below error msg.
TypeError: 'NoneType' object is not subscriptable
I am trying pull data for below json custom filed data
issue["fields"]["customfield_20590"]["name"]
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth import HTTPBasicAuth
import json
import csv
def JiraBoard():
url = "https://jiratest.com/rest/api/2/search"
auth = HTTPBasicAuth("test", "password")
headers = {
"Accept": "application/json"
}
query = {
'jql': 'project = DM', "startAt":1,
"maxResults":20
}
response = requests.request(
"GET",
url,
headers=headers,
params=query,
auth=auth
)
issues =(response.json()["issues"])
for issue in issues:
print(
issue["key"],
issue["id"],
issue["fields"]["customfield_20590"]["name"]
)
JiraBoard()
I am trying pull issue["fields"]["customfield_20590"]["name"] values data.
Hi @Rakesh Patil ,
You better use the atlassian python lib (pip install atlassian-python-api) and use this:
from atlassian import Jira
def JiraBoard():
jira = Jira(
url='https://jiratest.com',
username='test',
password='password'
)
jql = 'project = DM'
start_at = 1
max_results = 20
response = jira.jql(jql, start=start_at, limit=max_results)
issues = response['issues']
for issue in issues:
custom_field = issue['fields'].get('customfield_20590')
custom_field_name = custom_field.get('name') if custom_field else 'N/A'
print(
issue['key'],
issue['id'],
custom_field_name
)
JiraBoard()
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.