I have a custom field PK ID created in jira project(APT). i want to create a new issue of type story and set PK ID field value while creating the issue.
I am trying following code:-
IssueInputBuilder issueBuilder = new IssueInputBuilder("APT",10002L,"XYZ");
issueBuilder.setIssueTypeId(10001L);
//issueBuilder.setFieldValue("PK ID",new String("Hello"));
//issueBuilder.setFieldValue("customField_10013",new String("Hello"));
URI jiraServiceUri = new URI("<removed url>" + ":" + "8080");
JiraRestClient clientUtil = (JiraRestClient) new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(jiraServiceUri,"388961", "Jira@1234");
clientUtil.getIssueClient().createIssue(issueBuilder.build());
Issue not getting created when i use issueBuilder.setFieldValue() method.
How can i set value for PK ID custom filed while creating issue
What response do you get from jira? compare the json your are sending to jira with the json of an existing ticket in this project.
i would do something along the lines of:
Collection<FieldInput> issueProps = new ArrayList<FieldInput>();
IssueRestClient issueClient = jiraConnection.getIssueClient();
List<JiraField> fields = getRequiredFields();
for (JiraField field : fields) {
//System.err.println(field.getFieldId().trim());
String[] args = new String[] { field.getFieldId(), ""};
if ("PK ID".equalsIgnoreCase(field.getFieldId().trim())) {
args = new String[] { field.getFieldId(), "Hotline Ticket"};
}
if (args[1] != null && args[1].trim().length() > 0) {
field.setValue(args[1]);
// System.err.println(field.getValue());
issueProps.add(field.asFieldInput());
}
}
public List<JiraField> getRequiredFields() {
JiraSortedFieldCache fieldCache = new JiraSortedFieldCache();
fieldCache.loadFieldsFromFile();
return fieldCache.getCachedFields();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.