Jira issue type values for Rest api

2019-09-02 03:09发布

Where can I find Jira issue type values that we pass to IssueBuilder class constructor? For ex: If i want to create a issue type of bug using jira rest api , We pass value '1L' to Issue Builder class constructor.

IssueInputBuilder issueBuilder = new IssueInputBuilder("Key", 1l);

Similarly what are the values of other jira issue types ?.. Anybody know the values we need to pass ?

标签: java rest jira
2条回答
Rolldiameter
2楼-- · 2019-09-02 03:16

If you want to get a list of all available issuetypes, you can use the REST API (/rest/api/2/issuetype). To try that on your JIRA instance, I like to recommend the Atlassian REST API Browser.

Or just look here: Finding the Id for Issue Types

In Java you can get a list of all issuetype object using getAllIssueTypeObjects().

查看更多
霸刀☆藐视天下
3楼-- · 2019-09-02 03:21

If you are using later Jira REST Java Client API (e.g. 4.0), the interface has been changed. You must use following code to browsing all issue types:

private static final String JIRA_SERVER = "http://jiralab";

public static void main(String[] args) {
    try {
        JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
        URI uri = new URI(JIRA_SERVER);
        JiraRestClient client = factory.createWithBasicHttpAuthentication(uri, "admin", "admin");
        listAllIssueTypes(client);          
    }
    catch (Exception ex) {
    }
}

private static void listAllIssueTypes(JiraRestClient client) throws Exception {
    Promise<Iterable<IssueType>> promise = client.getMetadataClient().getIssueTypes();
    Iterable<IssueType> issueTypes = promise.claim();
    for (IssueType it : issueTypes) {
        System.out.println("Type ID = " + it.getId() + ", Name = " + it.getName());
    }
}
查看更多
登录 后发表回答