Update issue with jira-rest-java-client 2.0.0-m5

Luca Andreatta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2013

I build an application to create issue in jira using jira-rest-java-client version 1.0

Now I updated the lib version to 2.0.0-m5 because I need to update some issue, but I don't find how. I read from this issue that this version should implement it, but I don't find it.

How can I do it?

10 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

11 votes
Answer accepted
Bob Carroll June 5, 2013

I know it's been a few months, but I'll just leave this here for anyone who encounters the same issues I did...

Public documentation for JRJC is awful. The tutorial is for verison 1.0, the JavaDocs reference 0.4, and the website makes no reference to what the current version actually is. You have to look at the Maven repo to find that out. Version 1.1 seems to suppot updating but thanks to a bug in Apache Commons HTTP library, it doesn't work with my company's SSO gateway.

Atlassian forked httpclient and seems to be merging upstream changes in. But since the source code isn't available there's no way to know exactly what they changed. So I can't fix the bug without tearing out httpclient and replacing it with the supported version from Apache. And JRJC 2.0 is not useful to me because it's missing a bunch of needed functionality. I would add the missing functionality but the design is too ridiculously complicated.

So since all I really wanted was a library that *helped* I decided it was easier to write my own. If you're deciding between JRJC and an alcohol-induced coma, you might find https://github.com/rcarz/jira-client helpful.

TraollyX May 2, 2017

Bob, 

      With the latest JIRA v7.2.6, does your "jira-client" still work with that version of the REST API and would be easy to work with future versions? I am currently having issues with retrieving a simple ticket in our DEV system using the example from this link. 

https://github.com/rcarz/jira-client/tree/release-0.5

 

Please let me know your thoughts. 

 

Thanks. 

Traolly Xiong

 

Bob Carroll July 2, 2017

It should work. The public release is pretty old so you may need to pull master and build it. I'm working to get a bunch of PRs merged and tested before making a new public release.

0 votes
admin_site January 17, 2019

Any new on that in 2019 ?

0 votes
Vio ao October 23, 2013

issueBuilder.setFieldValue("customfield_10000", ComplexIssueInputFieldValue.with("value",customerId));

when I do this,there is an error like this:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Operation value must be a string
do you know why?

0 votes
Vladimir Vasic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2013

Hi Luca,

it would be great if you could post your pom.xml and code snippet here for issue creation in jira using jrjc-1.0, since I spent a lot of time trying to figure out right dependencies for the job.

0 votes
Umang Kedia February 11, 2013

Can you send me the link for 2.0.0-m5 release? I can't find the jar for it.

0 votes
TraollyX February 10, 2013

Thanks!

0 votes
TraollyX February 7, 2013

Interesting. If during creating of a jira issue in the UI allows one to select a custom drop down of

severity leve, would you agree that with the JRJC 1.0 transition will give you the capability

to change that custom field?

The other easiest way to do this is use the REST API it self in java using one of the other Jersey classes.

Thanks in advance.

TRX

Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 10, 2013

Transition is about changing state of existsing issue, so I don't see the connection beetween the create issue UI and possibility to change customfield while doing transition.

0 votes
TraollyX February 7, 2013

Can you elaborate what you mean by editable during transition?

I was able to edite the custom field via one of Jersey's class.

Thanks.

TRX

Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 7, 2013

When the transition is configured in a way that you can change field value (for example to fill the resolution field while using resolve transition) then rest client 1.0 is able to set that field when performing transition. But I suppose that this is not what you need.

As example see the assertTransitionWithNumericCustomField method: https://bitbucket.org/atlassian/jira-rest-java-client/src/f181d6425ba3fa8aa33f66c23c63f63471fcc44a/src/test/java/it/JerseyIssueRestClientTest.java?at=jira-rest-java-client-1.x

0 votes
TraollyX February 3, 2013

Is there any way to update a custom field with JRJC 1.0?

Any help is fully apreciated.

Regards,

TRX

Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 7, 2013

No, updating issues is not available in JRJC 1.0. You can only change values of fields that are editable during transition.

0 votes
Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 22, 2013

It's not yet possible in 2.0.0-m5. I've repoened that issue, sorry for the confusion.

The code need to be merged back from old 1.1 branch. You can use 1.1-m02 milestone release, but this code (the old 1.x version) rather won't be supported anymore.

Luca Andreatta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2013

Hi Aleksander,

I tried version 1.1-m02, but I can't update custom field.

I get this error:

Field 'My Custom Field Name' cannot be set. It is not on the appropriate screen, or unknown.

I updated them building a map like this:

List<FieldInput> fields = new ArrayList<FieldInput>();

fields.add(new FieldInput(fieldName, fieldValue));

issueClient.update(issue, fields, pm);

Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 28, 2013

I assume that you can edit this field in JIRA (so the screens are configured correctly).

The problem is that you're using field name instead of field id - you should pass something like customefield_10020 to the FieldInput as first parameter.

client.getIssueClient().update(issue, ImmutableList.of(
		new FieldInput("customfield_10020", "test value 1")
), pm);

Luca Andreatta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 28, 2013

Hi, I can edit the custom field in the JIRA edit screen and I tried your solution, but I didn't work.

The field is a CustomFieldOption, but it didn't work in any way that I tried.

If I put the first parameter as the name of the customField I get this:

Field 'Categoria Requisito' cannot be set. It is not on the appropriate screen, or unknown.
	at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:68)
	at com.atlassian.jira.rest.client.internal.jersey.JerseyIssueRestClient.update(JerseyIssueRestClient.java:223)
	at it.eng.api.jira.rest.RestClient.updateIssue(RestClient.java:185)

If I put the first parameter ad customfield_*** I get this error:

Could not find valid 'id' or 'value' in the Parent Option object.
	at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:68)
	at com.atlassian.jira.rest.client.internal.jersey.JerseyIssueRestClient.update(JerseyIssueRestClient.java:223)

Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2013

Hi,

for complex fields (those which contains more than a text or number) you need to use ComplexIssueInputFieldValue, as the REST API expect object there.

For Select List custom field (which I believe you're talking about) you may pass a option value or id:

// select by option id
client.getIssueClient().update(issue, ImmutableList.of(
		new FieldInput("customfield_10140", ComplexIssueInputFieldValue.with("id", "10022"))
), pm);

// select by option value
client.getIssueClient().update(issue, ImmutableList.of(
		new FieldInput("customfield_10140", ComplexIssueInputFieldValue.with("value", "green"))
), pm);

Does that solve your problem?

Jim Ryan February 20, 2013

Hi, Aleksander,

I'm right at this point ("Does that solve your problem?"). At first I got response 400 when attempting to update customfield_10006 (Rank). So, I let this field show in the screen. Now I get response 500 (Internal server error). I must be using the API incorrectly, in particular ComplexIssueFieldValue.with(). Can you help, please? Here is my code.

String fieldId = "customfield_10006";
final NullProgressMonitor pm = new NullProgressMonitor();
IssueRestClient irc = restClient.getIssueClient();
irc.update(issue, ImmutableList.of(new FieldInput(fieldId, ComplexIssueInputFieldValue.with("value", "22"))), pm);

The Issue object is fine. I can get the field from it and print its value (currently 28). So, I'm making a mistake on the last line, I think. Thank you for any help.

Jim Ryan February 20, 2013

Got it! I suppose my mistake was trying to update customfield_10006/Rank as I was. So, I created a custom numeric field and updated it.

String fieldId = "customfield_10006";
final NullProgressMonitor pm = new NullProgressMonitor();
IssueRestClient irc = restClient.getIssueClient();
restClient.getIssueClient().update(issue, ImmutableList.of(new FieldInput(fieldId, 22)), pm);

Now I have 1.1-m02 working with the update functionality. It would be nice to see this merged into a trunk release. Thank you!

Shane Mc May 2, 2013

Is it possible to create issues of type Epic via JRJC? I have managed to add stories and sub-tasks but when I try the same sort of code as the Story for an Epic issue type I get an exception message indicating the field "Epic Name" is required:

Exception in thread "main" com.atlassian.jira.rest.client.RestClientException: Epic Name is required.
at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:68)
at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.impl(AbstractJerseyRestClient.java:164)
at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.postAndParse(AbstractJerseyRestClient.java:152)
at com.atlassian.jira.rest.client.internal.jersey.JerseyIssueRestClient.createIssue(JerseyIssueRestClient.java:398)

Looking at JIRA it seems this is a custom field (customfield_12601) but it is not obvious how I should set this using the issueBuilder. Is there any documentation you can direct me to for this? Thanks.

Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 5, 2013

@omerta: this is separate question, so please create one instead of a comment in existing question (it's not related to this one).

In short: it should be possible by using IssueInputBuilder#setFieldValue("customfield_12601", "Epic name") - I didn't tested it but I believe it should work ;).

Shane Mc May 6, 2013

No joy with that I'm afraid. Thanks for the suggestion Alexsander. As requested here is new question: https://answers.atlassian.com/questions/166580/not-able-to-create-epic-issue-type-using-jira-rest-java-client-jrjc#

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events