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?
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.:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.