bobcarroll / jira-client

A simple JIRA REST client for Java
Other
473 stars 379 forks source link

Create issue language problem #223

Open stefanbildl opened 6 years ago

stefanbildl commented 6 years ago

Your Jira Client only allows posting new issues using the English issue type name. If i try to use the german issue type name, an Exception is thrown

net.rcarz.jiraclient.JiraException: Project 'TEST'  or issue type 'Aufgabe' missing from create metadata. Do you have enough permissions?
    at net.rcarz.jiraclient.Issue.getCreateMetadata(Issue.java:475)
    at net.rcarz.jiraclient.Issue.create(Issue.java:670)
    at net.rcarz.jiraclient.JiraClient.createIssue(JiraClient.java:77)
    at ...

This is caused, because in the "Issue" class, you query for possible issue types using query param "issuetypeNames" in the getCreateMetadata method:

here:

        try {
            URI createuri = restclient.buildURI(
                getBaseUri() + "issue/createmeta",
                new HashMap<String, String>() {{
                    put("expand", "projects.issuetypes.fields");
                    put("projectKeys", pval);
                    put("issuetypeNames", itval);
                }});
            result = restclient.get(createuri);
        } catch (Exception ex) {
            throw new JiraException("Failed to retrieve issue metadata", ex);
        }

Jira's REST API is a bit silly. You can only use English type names to filter for issuetypeNames, even though it uses german names itself. If I query all the available task types, only the german names are returned by the jira API....

The problem would be solved for me if a method Issue.createIssue(String project, int issueTypeId) existed, where you entered a Type ID instead of a type name.

I think the problem would be solved by substituting put("issuetypeNames", itval); with put("issuetypeIds", itval);

Thanks!