JIRA 9.5.1 : Unable to solve "Option id 'null' is not valid" error - Java API

Suave Devil
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 13, 2024

Hello everyone,

I have browsed extensively on this error, and people either say that the field name is wrong or the field value is wrong in their cases but I have tried all possible combinations to no avail.

I am using Java API for JIRA to create a new bug, and my company has a field called "Detected by Test Type" (customfield_15870). The accepted values are "Integration Testing", "Functional Testing" and "Performance Testing". Each look like this (I did a getField on this field from an existing bug and got individual values)

value: "Performance Testing" id: "12345" self: "https:///rest/api/2/customFieldOption/12345" disabled: false

This tells me I got the field name correct, and the individual values correct too.

Here is my code:

Map<String, Object> cascadingValues = new HashMap<String, Object>();
cascadingvalues.put("value",  "Performance Testing");
cascadingvalues.put("id",  "12345");
cascadingvalues.put("disabled",  false);
cascadingvalues.put("self",  "https://<url>/rest/api/2/customFieldOption/12345");

iib.setFieldValue("customfield_15870", new ComplexIssueInputFieldValue(cascadingValues));


I have tried these options as well:

    iib.setFieldValue("customfield_15870", ComplexIssueInputFieldValue.with("value", "Performance Testing"));
    iib.setFieldValue("customfield_15870", ComplexIssueInputFieldValue.with("id", "Performance Testing"));
    iib.setFieldValue("customfield_15870", ComplexIssueInputFieldValue.with("value", "12345"));
   
    iib.setFieldValue("customfield_15870", ComplexIssueInputFieldValue.with("id", "12345"));

And yet, it throws me the "Option id 'null' is not valid" error. Can someone please help?

Here is the stack trace:

RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={customfield_15870=Option id 'null' is not valid}, errorMessages=[]}]}
       at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:47)
       at com.bla.jira.IssueWriterBeta.createIssue(IssueWriterBeta.java:340)
       at com.bla.almutil.ConnectToJira.createEpic(ConnectToJira.java:282)
       at com.bla.almutil.ConnectToJira.main(ConnectToJira.java:378)
Caused by: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={customfield_15870=Option id 'null' is not valid}, errorMessages=[]}]}
       at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:173)
       at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:167)
       at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:48)
       at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:12)
       at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:295)
       at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:185)
       at com.google.common.util.concurrent.Futures$7.run(Futures.java:1072)
       at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
       at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:161)
       at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:146)
       at com.google.common.util.concurrent.AbstractFuture.done(AbstractFuture.java:235)
       at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:172)
       at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
       at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:295)
       at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:185)
       at com.google.common.util.concurrent.Futures$7.run(Futures.java:1072)
       at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
       at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:161)
       at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:146)
       at com.google.common.util.concurrent.AbstractFuture.done(AbstractFuture.java:235)
       at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:172)
       at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
       at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:46)
       at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:197)
       at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
       at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:192)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)

Thank you in advance!

1 answer

0 votes
Matt Parks
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.
April 15, 2024

Is this a Cascading Select List field? If so, is the child value required? It looks like you're setting the first value, but not the second.

To set the second value, I think this should work (or something very similar)

"customfield_15870": {"id":"12345", "child":{"id":"23456"}}

Suggest an answer

Log in or Sign up to answer