Redmine Java API addCustomField doesn't seem to be adding custom fields
Added by Jale Ipekoglu almost 8 years ago
Hello,
I am trying to create issues using Redmine Java API. I am able to successfully post the request to the server but it gives me the error about our mandatory custom field values.
Here is my code as I followed the instructions written in the README.md file;
String CUSTOM_FIELD_BRANCH = "Branch"; String CUSTOM_FIELD_COUNTRY = "Country"; String CUSTOM_FIELD_DOMAIN = "Domain"; String CUSTOM_FIELD_SUBMITTEDBY = "SubmittedBy"; String CUSTOM_FIELD_EMAILTO = "EmailTo"; RedmineManager mgr = RedmineManagerFactory.createWithApiKey(uri, apiAccessKey); IssueManager issueManager = mgr.getIssueManager(); Issue issueToCreate = IssueFactory.create(10, "some subject"); CustomFieldManager customFieldManager = mgr.getCustomFieldManager(); List<CustomFieldDefinition> customFieldDefinitions = customFieldManager.getCustomFieldDefinitions(); for (CustomFieldDefinition customFieldDefinition : customFieldDefinitions) { String customFieldName = customFieldDefinition.getName(); if (customFieldName.equals(CUSTOM_FIELD_BRANCH)) { issueToCreate.addCustomField(CustomFieldFactory.create(customFieldDefinition.getId(), customFieldDefinition.getName(), "branchValue")); }if (customFieldName.equals(CUSTOM_FIELD_COUNTRY)) { issueToCreate.addCustomField(CustomFieldFactory.create(customFieldDefinition.getId(), customFieldDefinition.getName(), "countryValue")); }if (customFieldName.equals(CUSTOM_FIELD_DOMAIN)) { issueToCreate.addCustomField(CustomFieldFactory.create(customFieldDefinition.getId(), customFieldDefinition.getName(), "domainValue")); }if (customFieldName.equals(CUSTOM_FIELD_SUBMITTEDBY)) { issueToCreate.addCustomField(CustomFieldFactory.create(customFieldDefinition.getId(), customFieldDefinition.getName(), "submittedByValue")); }if (customFieldName.equals(CUSTOM_FIELD_EMAILTO)) { issueToCreate.addCustomField(CustomFieldFactory.create(customFieldDefinition.getId(), customFieldDefinition.getName(), "xyz@abc.com.tr")); } Issue createdIssue = issueManager.createIssue(issueToCreate); //here I receive an exception
The exception is;
com.taskadapter.redmineapi.RedmineProcessingException: Branch cannot be blank Country cannot be blank Domain cannot be blank SubmittedBy cannot be blank EmailTo cannot be blank at com.taskadapter.redmineapi.internal.comm.redmine.RedmineErrorHandler.processContent(RedmineErrorHandler.java:57) at com.taskadapter.redmineapi.internal.comm.redmine.RedmineErrorHandler.processContent(RedmineErrorHandler.java:22) at com.taskadapter.redmineapi.internal.comm.ComposingHandler.processContent(ComposingHandler.java:25) at com.taskadapter.redmineapi.internal.comm.ComposingHandler.processContent(ComposingHandler.java:25) at com.taskadapter.redmineapi.internal.comm.BaseCommunicator.sendRequest(BaseCommunicator.java:47) at com.taskadapter.redmineapi.internal.comm.redmine.RedmineAuthenticator.sendRequest(RedmineAuthenticator.java:52) at com.taskadapter.redmineapi.internal.comm.FmapCommunicator.sendRequest(FmapCommunicator.java:26) at com.taskadapter.redmineapi.internal.comm.FmapCommunicator.sendRequest(FmapCommunicator.java:26) at com.taskadapter.redmineapi.internal.comm.BasicSimplifier.sendRequest(BasicSimplifier.java:24) at com.taskadapter.redmineapi.internal.Transport.send(Transport.java:590) at com.taskadapter.redmineapi.internal.Transport.addObject(Transport.java:229) at com.taskadapter.redmineapi.IssueManager.createIssue(IssueManager.java:155) at com.softtech.redmine.issuemanager.IssueCreator.main(IssueCreator.java:83)
Could you please help me what am I doing wrong?
Redmine API version is 3.0.0
All the values that I am passing as the third parameter to the addCustomField method are valid and in the possible values (except submittedBy and emailTo).
Thanks in advance,