Hi,
I am trying to apply a transition flow for an issue. This flow is like:
Open the issue → Start Progress → Add Work Log → Resolve the issue
I successfully completed the first three steps, however, I cannot resolve the issue.
To resolve the issue, “Time Spent” field is mandatory on the GUI screen.
When I don’t send any FieldInput to the TransitionInput, As expected I get an error like that:
RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={}, errorMessages=[Time Spent is required.]}]}
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:47)
at Main_Clean.main(Main.java:54)
However, when I send a FieldInput (timespent, resolution or any other field) to the TransitionInput, I get an error like:
RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={timespent=Field 'timespent' cannot be set. It is not on the appropriate screen, or unknown.}, errorMessages=[]}]}
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:47)
at Main_Clean.main(Main.java:54)
The code that I used:
public static void main(String[] args) {
try {
URI jiraServerUri = URI.create("http://companyjiratest:8080/");
AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
AuthenticationHandler auth = new BasicHttpAuthenticationHandler(username, password);
JiraRestClient restClient = factory.create(jiraServerUri, auth);
AsynchronousIssueRestClient issueClient = (AsynchronousIssueRestClient) restClient.getIssueClient();
// /* Creating issue */
// IssueInput issue = createJIRAIssue("ESD", "test1", "Issue from code.","id123", "Department", "");
// BasicIssue issueObj = issueClient.createIssue(issue).claim();
Promise<Issue> prom = issueClient.getIssue("ESD-113");
Issue theIssue = prom.claim();
Collection<FieldInput> fieldInput = (Collection) Arrays.asList(new FieldInput("timespent", "2h"));
Collection<FieldInput> fieldInputs = (Collection) Arrays.asList(new FieldInput("resolution", ComplexIssueInputFieldValue.with("name", "Resolve Issue"))); // Line 54 of Main.java file is that line
// /* Adding worklog */
// WorklogInputBuilder wiBuilder = new WorklogInputBuilder(theIssue.getWorklogUri());
// wiBuilder.setMinutesSpent(20);
// wiBuilder.setComment("comment for worklog");
// wiBuilder.setAdjustEstimateAuto();
// restClient.getIssueClient().addWorklog(theIssue.getWorklogUri(), wiBuilder.build());
TransitionInput transitionInput = new TransitionInput(21, fieldInput, Comment.valueOf("The comment")); // 21 is the id of resolving issue; got it from .../rest/api/2/issue/ESD-113/transitions
restClient.getIssueClient().transition(theIssue, transitionInput).claim();
restClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
For “Resolve” an issue, my JIRA server requires a field called “Time Spent”. The screen is same with “Log Work” screen, basically, when you resolve the issue, you should add a final time spent. When do this resolving manually from UI, the value that we entered on “Time Spent” field added as another work log.
So, in “Resolve” screen of UI, if I did not enter any value to “Time Spent” field and push the “Resolve” button, I get error with message “Time Spent is required.” (Exactly same with the message in exception.) as we can see from the image below.
In summary, I need to enter a “Time Spent” value to the required field but I cannot. How can I solve that problem? What am I missing in my code?