java - 如何使用 JIRA REST Java 客户端创建子任务

标签 java api jira

有没有办法使用 JRJC v1.0 创建子任务?我一直找不到关于此的任何好的文档。那里有示例代码吗?

它似乎不受库支持,但可以直接使用 REST API。

JIRA v5.1.5

最佳答案

我能够将以下有效的代码放在一起。

    IssueInputBuilder issueBuilder = new IssueInputBuilder("Project1", 5L);//5 is the id for subtask type. You can know the id of subtask type by querying this REST api /rest/api/2/issue/createmeta
    issueBuilder.setDescription(">> Test Description");
    issueBuilder.setSummary("Test summary");
    issueBuilder.setProjectKey("Project1");
    Map<String, Object> parent = new HashMap<String, Object>();
    parent.put("key", "SOMEISSUE-234");
    FieldInput parentField = new FieldInput("parent", new ComplexIssueInputFieldValue(parent));

    Map<String, Object> customField = new HashMap<String, Object>();
    customField.put("value", "someValue");//This is some custom field value on the subtask
    customField.put("id", "12345");//This is the id of the custom field. You can know this by calling REST GET for a manually created sub-task

    issueBuilder.setFieldInput(parentField);
    issueBuilder.setFieldValue("customfield_12345",  new ComplexIssueInputFieldValue(customField));//here again you have to query an existing subtask to know the "customfield_*" value

    com.atlassian.jira.rest.client.domain.input.IssueInput issueInput = issueBuilder.build();
    BasicIssue bIssue = restClient.getIssueClient().createIssue(issueInput, pm);    
    System.out.println(">>> " + bIssue.getKey());

关于java - 如何使用 JIRA REST Java 客户端创建子任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14699893/

相关文章:

java - 如何存储字节并将它们读回数组

java - 如何在 Java Android Spring 中接收验证错误

java - 参数化批量插入到Spring JDBC中

java - 如果语句导致变量无法解析,在语句之外定义变量会导致重复的局部变量吗?

api - 具有 API key 和 JWT token 的 Net Core API

api - twitter4j getOAuthRequestToken错误

java - 在java中使用REST API创建一个新的 "JIRA issue"

java - Jira REST API 时间跟踪 空

linux - 如何为 JIRA 和 Confluence 创建多个 URL?

java - JSF 中的数据表