I’ve been looking for a way to update custom fields in Jira 7+ using Java. The info I found online is either old or doesn’t cover everything. I checked a bunch of places but couldn’t find a complete answer.
I know there are posts about deleting issues, saving values to custom fields, and creating issues in Jira with Java. There’s also stuff about changing custom field values automatically and getting previous values of custom fields. But none of these really solved my problem.
I found a solution, but I can’t add it to those other posts because I’m new here and don’t have enough points yet. Does anyone know the current best way to update custom fields in Jira 7+ using Java? I’d be happy to share what I learned if it helps others too.
hey emma, jira api can be a pain! try using the jira-client library – init client, fetch the issue, then use setCustomField(). way easier than raw http requests. lemme know if u need more info!
I’ve encountered similar challenges with Jira customizations. In my experience, using the Atlassian SDK along with the Jira Java API offers more control and better performance than REST API calls, especially for complex operations. You can start by setting up your project with the Atlassian SDK, then create a JiraClient instance using the JiraClientFactory. After fetching the issue you wish to update, you can call the setCustomFieldValue() on the issue object. The SDK simplifies authentication and connection management. Despite a slight learning curve, this method provides long-term stability and easier maintenance.
I’ve worked with Jira’s API extensively, and updating custom fields in Jira 7+ using Java can be tricky. The most reliable method I’ve found is using the Jira REST API with a Java HTTP client like Apache HttpClient or OkHttp.
First, you’ll need to authenticate using either Basic Auth or OAuth. Then, you can send a PUT request to the /rest/api/2/issue/{issueIdOrKey} endpoint with a JSON payload containing the custom field updates.
Here’s a basic structure:
JSONObject fields = new JSONObject();
fields.put("customfield_10000", "New Value");
JSONObject issueUpdate = new JSONObject();
issueUpdate.put("fields", fields);
HttpPut request = new HttpPut(jiraUrl + "/rest/api/2/issue/" + issueKey);
request.setEntity(new StringEntity(issueUpdate.toString()));
Remember to handle exceptions and close resources properly. This method has worked well for me across various Jira versions.