Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Want to get the field name instead of id from jira rest api json file

Rahul Singh April 19, 2018
import random
import sys
import os
import jira.client
import json
import logging
import datetime
import base64
import requests
import urllib
import json
import smtplib
from jira.client import JIRA
from smtplib import SMTPException
from win32com.client import Dispatch
import win32com.client as win32
serverURL='http://ontrack-internal.mycompany.com'
query='project = SWDEV
jql='/rest/api/2/search?jql=%s' % urllib.parse.quote(query)
response=requests.get(serverURL+jql,verify=False,auth=("user","pass"))
#print (response.json())
#emailidset = set()
for issues in response.json()["issues"]:
tricat=(issues["fields"]["customfield_14307"])
print(tricat)

actually tricat variable gives the field value of jira ticket,but the json file has the value instead of field name.I need to get the name instead of numeric value.Please help?

1 answer

1 vote
Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2018

Hi Rahul,

This will return a fields name. Using Python JIRA

jira = JIRA('server': "http://<url>",
basic_auth=("user", pass))

fields
=jira.fields()

for field in fields:    
print(field["name"])

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events