API to get all field of selected issue type

Dhaval Mistry December 24, 2018

Hi, 

I am trying to create issue thru custom import utilities, we have custom attribute and we may add more in future.

 

I am trying to get list of all attribute for selected issue type. can you guide me how do I get the list of attribute of selected type.

below api help me to get all attribute but unable to understand how which one below to which issue type. 

curl --request GET \
  --url 'https://your-domain.atlassian.net/rest/api/3/field' \
  --header 'Authorization: Bearer ' \
  --header 'Accept: application/json'

2 answers

1 accepted

3 votes
Answer accepted
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 24, 2018

Hi @Dhaval Mistry

see this document for creating issues via rest

https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

Check the section

Getting metadata for creating issues examples

Dhaval Mistry December 24, 2018

Hi Tom, 

 

Thanks for your help. 

 

I am looking to get list of all fields for specific issues type based on project selection and point me which fields are marked required. 

 

I need that list not as admin but as read only user. So normal user can use my tool and get the list of fields detail they need to fill in their excel and map with my tool. 

 

Regards  

Dhaval M. 

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 25, 2018

Hi 

you can get a list of fields on an issue types edit screen using param

 Expand=projects.issuetyoes.fields

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-issue-createmeta-get

I definitely recommend the Jira REST API browser and the Postman utility app to explore.

I’m not sure off the top of my head if you need any admin rights to call metadata. But it’s the methods that are available .

To create an issue you will need a user to have create issue permissions 

Dhaval Mistry December 25, 2018

True Tom, I completely understood that we need write or create access to create  issue in selected project. which user already have but user doesn't have admin on project level.

 

My tool currently able to create issue with hardcode column. I want to extend my tool to next level where I can give list of column user needs to pass as part of import tool.

also in tool I can specified that (*) marked columns are required attribute. 

this way my tool can be use in future if any team introduce new column in that issue type, I dont need to modify my tool anymore. 

 

I am using REST API only. I can get list of column from below api 

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-field-get

 

But unable to find mapping which field are using in selected issuetype. 

 

In jira you create attribute as global and add same attribute in multiple issue type. JIRA should have some kind of mapping between field & issuetype and that I am unable to find which API can provide. 

 

According to me that API doesn't require any admin access. coz currently users are able to create issue thru JIRA UI, it mean jira has that API, JIRA is using those API to generate Create /edit issue UI. only point for me which API they are using internally. 

 

I hope they dont use screen api, coz screen API needs Admin rights.

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-screens-get

 

 

Thanks for your kind support. 

-Dhaval M.

Like Raffaele Messina likes this
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 26, 2018

Hi Dhaval

There is no way to bypass Jira user security.

I have called the createmeta method using an agent user (non-admin) and it returns the data required to create an issue.

using

http://localhost:8090/rest/api/2/issue/createmeta?projectKeys=FRO3&expand=projects.issuetypes.fields

you will get the list of issue types available in a project and within the issues a list of fields available and their types  including whether they are mandatory. For select lists the allowed values are shown. This is the most complete information available and is the meta data required fro creating an issue.

I'm afraid I can't provide anything more helpful to you.

 

{
"expand": "projects",
"projects": [
{
"expand": "issuetypes",
"self": "http://localhost:8090/rest/api/2/project/10000",
"id": "10000",
"key": "FRO3",
"name": "fro3",
"avatarUrls": {
"48x48": "http://localhost:8090/secure/projectavatar?avatarId=10324",
"24x24": "http://localhost:8090/secure/projectavatar?size=small&avatarId=10324",
"16x16": "http://localhost:8090/secure/projectavatar?size=xsmall&avatarId=10324",
"32x32": "http://localhost:8090/secure/projectavatar?size=medium&avatarId=10324"
},
"issuetypes": [
{
"self": "http://localhost:8090/rest/api/2/issuetype/10000",
"id": "10000",
"description": "A task that needs to be done.",
"iconUrl": "http://localhost:8090/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype",
"name": "Task",
"subtask": false,
"expand": "fields",
"fields": {
"summary": {
"required": true,
"schema": {
"type": "string",
"system": "summary"
},
"name": "Summary",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"issuetype": {
"required": true,
"schema": {
"type": "issuetype",
"system": "issuetype"
},
"name": "Issue Type",
"hasDefaultValue": false,
"operations": [],
"allowedValues": [
{
"self": "http://localhost:8090/rest/api/2/issuetype/10000",
"id": "10000",
"description": "A task that needs to be done.",
"iconUrl": "http://localhost:8090/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype",
"name": "Task",
"subtask": false,
"avatarId": 10318
}
]
},
"description": {
"required": false,
"schema": {
"type": "string",
"system": "description"
},
"name": "Description",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"project": {
"required": true,
"schema": {
"type": "project",
"system": "project"
},
"name": "Project",
"hasDefaultValue": false,
"operations": [
"set"
],
"allowedValues": [
{
"self": "http://localhost:8090/rest/api/2/project/10000",
"id": "10000",
"key": "FRO3",
"name": "fro3",
"avatarUrls": {
"48x48": "http://localhost:8090/secure/projectavatar?avatarId=10324",
"24x24": "http://localhost:8090/secure/projectavatar?size=small&avatarId=10324",
"16x16": "http://localhost:8090/secure/projectavatar?size=xsmall&avatarId=10324",
"32x32": "http://localhost:8090/secure/projectavatar?size=medium&avatarId=10324"
}
}
]
},
"reporter": {
"required": true,
"schema": {
"type": "user",
"system": "reporter"
},
"name": "Reporter",
"autoCompleteUrl": "http://localhost:8090/rest/api/latest/user/search?username=",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"customfield_10133": {
"required": false,
"schema": {
"type": "group",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:grouppicker",
"customId": 10133
},
"name": "Group Field",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"priority": {
"required": false,
"schema": {
"type": "priority",
"system": "priority"
},
"name": "Priority",
"hasDefaultValue": true,
"operations": [
"set"
],
"allowedValues": [
{
"self": "http://localhost:8090/rest/api/2/priority/1",
"iconUrl": "http://localhost:8090/images/icons/priorities/highest.svg",
"name": "Highest",
"id": "1"
},
{
"self": "http://localhost:8090/rest/api/2/priority/2",
"iconUrl": "http://localhost:8090/images/icons/priorities/high.svg",
"name": "High",
"id": "2"
},
{
"self": "http://localhost:8090/rest/api/2/priority/3",
"iconUrl": "http://localhost:8090/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
},
{
"self": "http://localhost:8090/rest/api/2/priority/4",
"iconUrl": "http://localhost:8090/images/icons/priorities/low.svg",
"name": "Low",
"id": "4"
},
{
"self": "http://localhost:8090/rest/api/2/priority/5",
"iconUrl": "http://localhost:8090/images/icons/priorities/lowest.svg",
"name": "Lowest",
"id": "5"
},
{
"self": "http://localhost:8090/rest/api/2/priority/10000",
"iconUrl": "http://localhost:8090/images/icons/priorities/blocker.svg",
"name": "Blocker",
"id": "10000"
},
{
"self": "http://localhost:8090/rest/api/2/priority/10001",
"iconUrl": "http://localhost:8090/images/icons/priorities/trivial.svg",
"name": "Minor",
"id": "10001"
}
]
},
etc. etc.
Like # people like this
Dhaval Mistry December 27, 2018

This is what I was looking for, Thanks Tom for you help.

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2018

Glad to have helped. Could you mark it as an accepted answers other users can find it?

Kin November 27, 2020

Thnx, solution works for me. 

However when getting results from (one) issue context, the structure is different
where fields of issuetype "task" are placed directly in the path of "issues[0].fields".
Fields of ie, "subtasks" are placed in the path "issues[0].fields.subtasks".

Payas Hasteer June 22, 2023

I was trying to make this work in GoLang could any one suggest on how to do that? This is the library I am using. I am having problem expanding the fields inside IssueTypes. 
https://github.com/andygrunwald/go-jira

0 votes
Pritish Pattanaik October 9, 2019

I traverse issue.raw['fields'] in for loop to get required field and their name 

 

try:
    issue = Jira.issue(issueref)
    except JIRAError as e:
    return 'Error:' + str(e.text)
else:
     for field in issue.raw['fields']:
         if re.search('^(priority|assignee|status|issuetype|project)$', field):
         JiraData += field + ':' + str(issue.raw['fields'][field]['name']) + "\n"

Suggest an answer

Log in or Sign up to answer