Forums

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

How to get issues types of a specific project using Jira REST Java Client (JRJC)?

Efrat Gordon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 9, 2019

I'm trying to get all issues types per project.
I tried to use :

jiraRestClient.getMetadataClient().getIssueTypes(pm)

but I get the types of all projects.
is there a way to get issues types for a specific project using JRJC?

1 answer

1 vote
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2019

Hi @Efrat Gordon ,

The endpoint /rest/api/2/issuetype returns all the issue types the user has access to.

The way to get only the issue types for a specific project is to call the endpoint /rest/api/2/issue/createmeta  and filter per project key or project id. E.g.:

  • https://INSTANCE//rest/api/2/issue/createmeta?projectKeys=TST,XYZ
  • https://INSTANCE//rest/api/2/issue/createmeta?projectIds=10000,10001

For more examples you can also see:

 

 

Therefore, even if I have never used JRJC myself, it looks like you need to use: 

issueClient.getCreateIssueMetadata()

 

There  is an example on how to use this in: 

 

@Test

public void testJRJC97 () {

final JerseyJiraRestClientFactory clientFactory = new JerseyJiraRestClientFactory();
final JiraRestClient restClient = clientFactory.createWithBasicHttpAuthentication(URI.create("http://localhost:2990/jira"), "admin", "admin");
final IssueRestClient issueClient = restClient.getIssueClient();

final Iterable<CimProject> metadataProjects = issueClient.getCreateIssueMetadata(new GetCreateIssueMetadataOptionsBuilder()
.withIssueTypeNames("Bug")
.withProjectKeys("TST")
.withExpandedIssueTypesFields()
.build(), pm);

 
// get project
final CimProject project = metadataProjects.iterator().next();


// get issue type by name
final CimIssueType bug = EntityHelper.findEntityByName(project.getIssueTypes(), "Bug");
 

// get issue type field
final CimFieldInfo issuetypeField = bug.getFields().get("issuetype");
assertEquals("Issue Type", issuetypeField.getName());
 

// get allowed value for issue type
final BasicIssueType issueTypeAllowedValue = (BasicIssueType)issuetypeField.getAllowedValues().iterator().next();
assertEquals(URI.create("http://localhost:2990/jira/rest/api/2/issuetype/1"), issueTypeAllowedValue.getSelf());

 

Finally, this might not be the best place to get help with this, in case of further help you might want to ask the same question in the developers community or open a ticket in the developers' service desk:

 

I hope this helps.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events