with JIRA REST Java Client Library, how to update issues by deleting values of fields

Runa January 21, 2018
I use JIRA REST Java Client Library 4.0.0.
https://ecosystem.atlassian.net/wiki/spaces/JRJC/overview

I want to update issues by deleting values of duedate and the following types of customfields with it.
・datepicker
・datetime
・userpicker
・float
・select list
・cascadingselect
・radiobuttons

Could you show me how to update issues by deleting values of these with JIRA REST Java Client Library?

The following is my source code. It can't update issues by deleting values.

JiraRestClientFactory jrcf = new AsynchronousJiraRestClientFactory();
JiraRestClient jrc = jrcf.createWithBasicHttpAuthentication(new URI([JIRAURL]), [USERID], [PASSWORD]);
IssueRestClient irc = jrc.getIssueClient();

Map<String, FieldInput> valMap = new HashMap<String, FieldInput>();
valMap.put("duedate", new FieldInput("duedate", null));
valMap.put("customfield_[CUSTOMFIELDID]", new FieldInput("customfield_[CUSTOMFIELDID]", null));

IssueInput ii = new IssueInput(valMap);
irc.updateIssue("[ISSUEKEY]", ii).claim();

1 answer

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

Hi Runa,

There is a Suggestion titled Add, edit, or delete custom fields in REST API that provides a third party add-on which may be of use:

It would be nice to be able to deal with custom fields using Jira REST API.

At the moment, it's possible to get some info by retrieving editmeta :

 http://example.com:8080/jira/rest/api/2/issue/{issueIdOrKey}/editmeta

But you cannot add, edit, or delete custom fields via JIRA REST API (as you can in the admin section).

Workaround

The third party plugin Jira Customfield Editor provides REST endpoints for the CRUD operations on custom fields.

Please take a look at the Suggestion and vote on JRASERVER-28539 or JRACLOUD-28539 depending on whether you are using Server or Cloud to provide impact and be notified of any changes to the ticket.

Cheers,

Branden

admin_site January 17, 2019

any news on that in 2019?

Runa January 23, 2019

After all, I'm not using JIRA REST because it is slow.

But at that time I tried to customize the library, and  customizing as follows, I could update issues by deleting values of fields.

In jira-rest-java-client-core-4.0.0.jar, com.atlassian.jira.rest.client.internal.json.gen.IssueInputJsonGenerator.java, comment out line 40 and 43

// if (field.getValue() !=null) {    // line 40

// }                                           // line 43

And to not throw exception, in case of deleting values of components, I set a instance of  ArrayList<ComplexIssueInputFieldValue> to the field value instead of null.

Suggest an answer

Log in or Sign up to answer