Hello,
I want to update a custom field value in my Issue via the new REST API.
I try to use the jira-rest-java-client JRJC for that.
So far i can Get the issue, Get the transition fields but the problem is that the custom field i try to edit is not in the transition fields list.
It seems its not so mutch related to the JRJC but more that the field is not in the list.
If i access the transition field list directly via browser i all so can not see the field. e.q
https://jiraurl/rest/api/latest/issue/XXX-123/transitions?expand=transitions.fields
So the question is how do i get the custom field into the transitions.fields list.
Or is there a way to update Issue field values without them being in the list ?
All the best,
Andrel
Community moderators have prevented the ability to post new answers.
Hey,
Good point Aleksander :)
Not so familar with the project jet, but will give it a try soon.
Since the update feature is somewhat present in 1.x version or JRJC and saw some comments that it will be ported to 2.0 soon thought that my hack solution is not worth commiting :)
Hmm
will give the mvn dependency:list a second try :)
Think most of the conflicts arose because i will use JRJC inside my application that allready has a lot of dependencies :)
Since the update feature is somewhat present in 1.x version or JRJC and saw some comments that it will be ported to 2.0 soon thought that my hack solution is not worth commiting :)
We're not going to do so in the near future - I'm happy to review and merge pull requests, but I don't have enought time now to implement or port the features by myself.
Run dependency:list on both JRJC and your project, and compare them - then you'll find which libraries are included in wrong wersion. For why, you'll probably want to play with mvn dependency:tree ;).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Sorry for the Rest api method which I suggested you,
use this, this will work
You jus need to specify the issue and just pass the customfield id and value to field param,
check the rest api documentation, regarding this.Thanks
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you tell me do you have the field in the desired transition screen.If not please add and do the transition and updation of fields using rest.
To check whether the field exists in the desired transition screen.
Administration - > projects -> select the project -> under the workflow -> select the workflow -> click on the transition -> check which screen does it use -> check whether you have the field-> if it doesn't exist -> add the field to the screen.
Hope this Helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use this to update issue
/rest/api/2/issue/{issueIdOrKey}/transitions(POST)
check here
for
some sample code
https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues
https://developer.atlassian.com/display/JIRADEV/Updating+an+Issue+via+the+JIRA+REST+APIs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
Yes, but should the field be in the transitons fields list ?
/rest/api/2/issue/STMT-328/transitions?expand=transitions.fields
before i can do the update POST ?
Or its not needed ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Offcourse it has to be in the transition field list, other wise it may give an error field unreachable or field not exist in the screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if you want to just edit the issue then you can try with
/rest/api/2/issue/QA-31(PUT), for this check the first link in my answer or if you want to update fields while transition then check the second link and try with API in answer(in this case fields should be there on transition screen which you are trying to update)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
Just wanted to write some comments, so maybe it saves some time for others in the future.
For rest calls im using 2.0.0.23 version of JRJC. Needed to do a lot of experimentation finding the correct dependencies (and im still not sure if i have the correct ones :) )
So how i got the editing of a existing issue fields working.
What i needed was a really simple one issue field update.
Since updating of a Issue is not ported to 2.0 i needed to overide the AsynchronousJiraRestClient and add a custom AsynchronousIssueRestClient to it.
Added a method to my custom AsynchronousIssueRestClient
@Override
public Promise<Void> updateIssue(final String issueKey, final IssueInput issue)
{
final UriBuilder uriBuilder = UriBuilder.fromUri(issueUri);
return put(uriBuilder.path(issueKey).build(), issue, new IssueUpdateInputJsonGenerator());
}
Created a custom PUT without parse method
@Override
public final Promise<Void> put(final URI uri, IssueInput entity, final IssueUpdateInputJsonGenerator jsonGenerator)
{
final ResponsePromise responsePromise = client().newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.put();
return call(responsePromise);
}
Now sad is that toEntity(jsonGenerator, entity) is a private method, so i needed to copy it from the superclass and paste it into my implementation.
Next i took the IssueInputJsonGenerator class and tweaked it to my own
public class IssueUpdateInputJsonGenerator implements JsonGenerator<IssueInput>
Tweaked because you can not create a issue input entity without project and type
Currently i still have some problems.
updateIssue(issueKey, IssueInput issue).claim() stops all threads in my application, so i can not use it.
updateIssue(issueKey, IssueInput issue) without claim works great, only problem is that with every request a new httpclient thred is created and after 4-5 updates
my CPU is at 100% :(
So my current solution is a dirty hack :(
I just kill the request with updateIssue(issueKey, IssueInput issue).get(1, TimeUtil.SECOND) and discard the exception.
Issue in Jira is updated and CPU stais normal.
In addition some more notes for JRJC development team.
a) restClient.close();
Does not work for me. Might be my dependency configuration or the problem that main http connection is closed, but the sub clients (AsynchronousIssueRestClient, AsynchronousUserRestClient etc.) do not implement the DisposableHttpClient, but just the HttpClient)
b) Issue Status field does not have a getId() property. Really unplesant finding, since i want to update the status in my application.
c) Implement public final Promise<Void> put(final URI uri, I entity, final IssueUpdateInputJsonGenerator jsonGenerator){...} for AsynchronousIssueRestClient (its used for updating the issue.
d) IssueInputBuilder should have a constructor with 0 parameters. Currently project and type are always needed new IssueInputBuilder(getProject(), getIssueType())
Since i dont need to update project and type i need to remove these field in the Json generation level :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, why you don't contribute to JRJC (it's open source) and submit fixes for that problems? Then you won't need to copy&paste any methods - just fix that in core classes and send pull request (including tests of course) :).
The IssueInputBuilder doesn't have 0 parameters constructor as it was designed for issue creation. But this can be changed ;).
To get the list of dependencies just run 'mvn dependency:list' in JRJC project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank to all,
Finaly figured out what did i not understand :)
First i completly missed the
/rest/api/2/issue/{issueIdOrKey} Put Method
From the api. And was thinking transition is needed for "just editing" the issue.
Now i just need to find how to "just edit" the issu via JRJC :P
Learning every day,
Andrel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you can update the fields alone, using the following REST Call using the Rest api
Supply the value that you want to update to the field param
https://docs.atlassian.com/jira/REST/latest/#idp2007632
Look at the above link search for the post method in /rest/api/2/issue
it will tell you how to do it.
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
TY for a quick responce
In the Doc it says
Creates an issue or a sub-task from a JSON representation.
Its for creating the Issue, not editing it ?
Or is the documentation missleading :|
According to the document, Editing the Issue should be done via
Perform a transition on an issue. When performing the transition you can udate or set other issue fields.
https://docs.atlassian.com/jira/REST/latest/#idp2067664
Confused,
Andrel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.