Is there a way to create a subtask using JRJC v1.0? I've been unable to find any good documentation on this. Any sample codes out there?
It seems like it's not supported via the library but possible using straight REST API.
JIRA v5.1.5
I was able to put together the below code that worked.
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With