Hi,
I am trying to resolve an issue which status is "In Progress". I got an error called "Time Spent is required". How can I solve that?
The code snip that I tried:
TransitionInput transitionInput = new TransitionInput(21, Comment.valueOf("The comment for completion"));
restClient.getIssueClient().transition(theIssue.getTransitionUri(), transitionInput).claim(); // restClient is JiraRestClient object. theIssue is in type Issue
I tried adding FieldInput object with key "timeSpent" and it did not work, too.
Thanks already for your answers.
Hi!
Let's input worklog first, WorklogInput will help you
https://docs.atlassian.com/jira-rest-java-client-api/2.0.0-m31/jira-rest-java-client-api/apidocs/
like this
public boolean addWorklog(IssueEx issue, String comment) {
try {
URI worklogUri = getIssue(issue.id).getWorklogUri();
WorklogInputBuilder wlBuilder = new WorklogInputBuilder(worklogUri);
wlBuilder.setMinutesSpent(issue.timeSpent);
wlBuilder.setComment(comment);
jiraRestClient.getIssueClient().addWorklog( worklogUri, wlBuilder.build() );
return true;
} catch (Exception e) {
LOGGER.warning( "jira rest client update issue error. cause: " + e.getMessage() );
return false;
}
}
Hope it helps
Cheers,
Gonchik Tsymzhitov
Hi, Gonchik. Thanks for your comment.
I tried the code that you gave and I got an error as follows. What should I do?
Exception in thread "Thread-1" java.util.concurrent.RejectedExecutionException: Task com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable@3f10924d rejected from java.util.concurrent.ThreadPoolExecutor@39e30c40[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateExecutor.execute(SettableFuturePromiseHttpPromiseAsyncClient.java:171)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1.doCancelled(SettableFuturePromiseHttpPromiseAsyncClient.java:68)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalContextAwareFutureCallback$3.run(SettableFuturePromiseHttpPromiseAsyncClient.java:152)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalContextAwareFutureCallback.cancelled(SettableFuturePromiseHttpPromiseAsyncClient.java:147)
at org.apache.http.impl.client.cache.CachingHttpAsyncClient$2.cancelled(CachingHttpAsyncClient.java:636)
at org.apache.http.concurrent.BasicFuture.cancel(BasicFuture.java:135)
at org.apache.http.impl.nio.client.DefaultResultCallback.cancelled(DefaultResultCallback.java:57)
at org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.cancel(DefaultAsyncRequestDirector.java:533)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.doExecute(AbstractHttpAsyncClient.java:471)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.access$000(AbstractHttpAsyncClient.java:101)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient$1.run(AbstractHttpAsyncClient.java:485)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can add the worklog like you said Gonchik, thanks.
However, I cannot still resolve the issue. It says "Time Spent is required", again :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, have you checked in UI worklog has been added?
Also can you confirm, is it possible resolve issue from UI?
Looks like your validator in Jira does not work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeap, worklog(s) has added and I can resolve issue from UI.
"Time Spent" fields is required in "Required Close Screen". Because of that I got "Time Spent is required" error.
Also, in UI, if I don't enter any value in "Time Spent" field, I got the same error in UI, too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, after addWorkLog method have you seen any changes in UI?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, in issue's page, a work log added after addWorkLog method. For that, additionally I add a ".claim()" at the end of the
jiraRestClient.getIssueClient().addWorklog( worklogUri, wlBuilder.build() );
line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.