How to get issue field structure using Jira Rest API v2?

AbdelrhmanE January 22, 2019

 

The Problem: I am trying to creating an issue using the API and have two cases:
- Case 1: Created project  when I select (I am  `experienced` with Jira) from recommendation page in project creation steps and send the data with priority and it worked


- Case 2: Created project when I select  (I am  `new` with Jira) from recommendation page in project creation steps and send priority and it didn't work.


Question: how I can detect Case 2 using the API provided

2 answers

1 accepted

1 vote
Answer accepted
Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 22, 2019

Dear @AbdelrhmanE,

can you please post both API calls?

Thanks

Thomas

AbdelrhmanE January 23, 2019

Dear @Thomas Deiler 

Thank you for the quick reply.

 

It is the same issue creation API (`POST /rest/api/2/issue`) with the same payload, 

The two cases is on different jira project

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 23, 2019

Dear @AbdelrhmanE,

then I continue guessing:

  • different permission schemes preventing issue creation or assigning issues
  • different set of fields (with mandatory options) that cannot be filled with data

Can you please post your json payload?

So long

Thomas

AbdelrhmanE January 23, 2019

Dear @Thomas Deiler

Yup the second option (a different set of fields (with mandatory options) that cannot be filled with data)

 

When I try to create an issue from Jira dashboard I didn't find the `priority` field

How can I get all supported fields using API?  

 

payload

```

{
fields: {
issuetype: {
id: issuetypeId,
},
labels: [],
project: {
key: projectKey,
},
summary: '',
description: '',
assignee: {
name: assigneeId,
},
priority: {
id: priorityId,
}
},
}

```

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 23, 2019

Dear @AbdelrhmanE,

only fields that are visible/editable via Jira UI will be also writeable over the REST API. Add priority to the 'create screen' of the issue type you want to create.

So long

Thomas

AbdelrhmanE January 27, 2019

Dear @Thomas Deiler

I don't want to add priority to the screen I need to know the supported fields before submission to restructure the suitable payload for it.

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 29, 2019

Afaik, when quering an issue you get all custom fields / system fields, regardless if they are shown on the screen, but filled with NULL if there is no value.

You need the knowledge of the create screen when caling the API.

AbdelrhmanE January 29, 2019

Dear @Thomas Deiler

 

I want to create a new issue not get existing one.

But before creating this issue through API I need to get issue structure (optional/required fields) using API to format the issue creation payload against it.

 

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 29, 2019

Dear @AbdelrhmanE,

you can perform a

GET /rest/api/2/issue/createmeta?expand=projects.issuetypes.fields

All fields are returned for all projects where you can create issues with your requesting account.

So long

Thomas

Like AbdelrhmanE likes this
0 votes
Prem Singh September 9, 2020

how to change the severity of the defect in jira usning rest api?

Suggest an answer

Log in or Sign up to answer