It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

API to get all field of selected issue type

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

2 votes
Answer accepted
tom lister Community Leader Dec 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

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. 

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 

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.

tom lister Community Leader Dec 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 Dhaval Mistry likes this

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

tom lister Community Leader Dec 27, 2018

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

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
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

342 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you