Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating ticket with custom field fails for call with jira - rest - client -core

Abhija Jayan
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!
February 5, 2024

I use rest api via jira-rest-java-client-core to create the ticket from a springboot rest service.


I have a custom field in the project of type - drop down list. But when I try to set it up with the below code , it is throwing error . What could be the reason for it


,,,,,,,,,,,,,,,,,,,,,

if (Utility.notEmpty(fixedInVersion)) {

issueBuilder.setFieldInput(new FieldInput("customfield_12426", fixedInVersion));

}

````````````````````````

IssueInput newIssue = issueBuilder.build();

BasicIssue issue = restClient.getIssueClient().createIssue(newIssue).claim();


Error : An exception occurred while generating the ticket: Ticket generation failed - Failed to create ticket with jira rest client[ErrorCollection{status=400, errors={customfield_12426=Could not find valid 'id' or 'value' in the Parent Option object.}, errorMessages=[]}]


rest - java - client - core version :

 

<dependency>

<groupId>com.atlassian.jira</groupId>

<artifactId>jira-rest-java-client-core</artifactId>

<version>5.2.0</version>

</dependency>

1 answer

1 accepted

0 votes
Answer accepted
Megha Rajanna
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.
February 5, 2024
The error you're encountering suggests an issue with setting the value for the custom field of type "drop-down list" (customfield_12426). It seems like the value you are trying to set (fixedInVersion) might not be recognized or is not in the correct format.
 
Here are a few things you can check and try:
 
Ensure Valid Option Value:
Make sure that the value you are trying to set for the drop-down list (fixedInVersion) is a valid option for that field. The value should match one of the available options exactly.
 
Use Option ID:
Custom fields of type "drop-down list" often have an underlying set of options with associated IDs. Instead of using the option's display value (fixedInVersion), try using its ID if you have access to it.
 
java
Copy code
if (Utility.notEmpty(fixedInVersionID)) {
    issueBuilder.setFieldInput(new FieldInput("customfield_12426", ComplexIssueInputFieldValue.with("id", fixedInVersionID)));
}
Check Field Configuration:
Verify that the field configuration for the project allows the provided value. Sometimes, there might be specific configurations or restrictions on the field that prevent certain values.
 
Upgrade Library Version:
The version 5.2.0 of jira-rest-java-client-core might have some issues, and upgrading to a more recent version might resolve the problem. Check the Atlassian Maven Repository for the latest version and consider upgrading.
 
xml
Copy code
<dependency>
    <groupId>com.atlassian.jira</groupId>
    <artifactId>jira-rest-java-client-core</artifactId>
    <version>latest-version</version>
</dependency>
Check Jira Server Logs:
Examine the Jira server logs for more details on the error. The logs may provide additional information on why the provided value is not accepted.
 
Validate Field Input:
Before creating the issue, you can validate the field input to see if there are any issues with the values you are trying to set.
 
java code:
ValidationResult validationResult = restClient.getIssueClient().validateIssue(issueBuilder.build());
if (!validationResult.isValid()) {
    System.out.println(validationResult.getErrorCollection());
}
Make sure to adapt the code snippets according to your application's context.
THANK YOU

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events