Hello,
I can't for the life of me figure out how to set a custom field value when creating an issue.
List<ComplexIssueInputFieldValue> fieldList = new ArrayList<ComplexIssueInputFieldValue>();
Map<String, Object> mapValues = new HashMap<String, Object>();
mapValues.put("value", "suite.robot");
ComplexIssueInputFieldValue fieldValue = new ComplexIssueInputFieldValue(mapValues);
fieldList.add(fieldValue);
issueInputBuilder.setFieldValue("customfield_10200", fieldList);
But that keeps throwing this error:
Caused by: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={customfield_10200=string expected at index 0}, errorMessages=[]}]}
I've seen a lot of other links about the multiple, multiple ways people have done this in the past, but I can't tell if the code has been versioned since then. I'm using 2.0.0-m19.
Thanks!
Community moderators have prevented the ability to post new answers.
After googling around and looking at forums and even talking to Jira support, the solution is simple...don't use the Jira REST client :) ... it's not maintained, the documentation is horribly out of date, and the best answer I could get was that it "wasn't officially supported, please read the API documentation".
Makes you wonder why Jira says it's the "easiest place to get started" ... I guess it is for super basic tasks, but if you need to do anything complex, you're better off writing your own little REST client. Short answer: Don't use the Jira REST client.
Another good answer is: it depends on custom field. If it's just a string field then issueInputBuilder.setFieldValue("customfield_10200", "string value"); should do the job.
For a label you need a list of strings there - to be sure just check the schema of that field.
issueInputBuilder.setFieldValue("customfield_10200", ImmutableList.of("label1", "label2"));
Tested and the code above works fine for me.
The best documentation for JRJC is the code itself + integration tests ;).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anyone? Just trying to create an issue with a custom field, whose type is "label". I can't find a straightforward way to do it using the Java rest client. I'm very close to scrapping the rest client altogether.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
// I found it after a long fight: Labels are given as array of "simple" values (display-names) only, no map:
// Assume String value = "Label1,Label2,Label3";
// and builder is an already well-formed IssueInputBuilder...
// Then, this work for me:
List<String> fieldListlabel = new ArrayList<String>();
String[] labels = value.split(",");
for (String aLabel : labels) {
if (aLabel == null || aLabel.isEmpty()) {
continue;
}
fieldListlabel.add(aLabel);
}
builder.setFieldValue("customfield_11209", fieldListlabel);
// ...
Did you have a hint for creating an issue withcustom field of type "option-with-child" i.e., cascading selection field?
I am fiting for it now... it seams, I am loosing ... F1!
Thank you.
PS: Following Code did not work for me:
ComplexIssueInputFieldValue headOpt = ComplexIssueInputFieldValue.with("value", "TV");
ComplexIssueInputFieldValue tailOpt = ComplexIssueInputFieldValue.with("child", ComplexIssueInputFieldValue.with("value", "ARD"));
Set<ComplexIssueInputFieldValue> cascade = new HashSet<ComplexIssueInputFieldValue>();
cascade.add(tailOpt);
cascade.add(headOpt);
builder.setFieldValue("customfield_11207", cascade);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.