Forums

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

Getting net.rcarz.jiraclient.RestException: 400 for multiselect custom field in Jira

Aamir Murtaza
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!
July 9, 2021

 am unable to create ticket when passing details of custom field. getting 400 bad request with message as mentioned below : net.rcarz.jiraclient.RestException: 400 : {"errorMessages":[],"errors":{"Customer":"expected Object"}}

Field Details:

customfield_1003={"required":true,"schema":{"type":"array","items":"option","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiselect","customId":1003},"name":"Customer","fieldId":"customfield_1003","hasDefaultValue":false,"operations":["add","set","remove"],"allowedValues":[{"self":""}]}

Tried multiple ways as bellow but no luck:

1.

            FluentCreate newIssueFluentCreate = jira.createIssue(project, issueType);
            newIssueFluentCreate.field(Field.SUMMARY, summary);
            newIssueFluentCreate.field("customfield_1003", new ArrayList<Object>() {{add(customer);}});
            newIssueFluentCreate.field(Field.DESCRIPTION, description);
            newIssueFluentCreate.field(Field.LABELS, new ArrayList<Object>() {{add(label);}});
            newIssueFluentCreate.field(Field.PRIORITY, "Minor");
            newIssue = newIssueFluentCreate.execute();
            JSONObject customerObject = new JSONObject();
            customerObject.put("value", "1225");            
            ArrayList<Object> customers = new ArrayList<>();
            customers.add(customerObject);
            
            FluentCreate newIssueFluentCreate = jira.createIssue(project, issueType);
            newIssueFluentCreate.field(Field.SUMMARY, summary);
            newIssueFluentCreate.field("customfield_1003", customers);
            newIssueFluentCreate.field(Field.DESCRIPTION, description);
            newIssueFluentCreate.field(Field.LABELS, new ArrayList<Object>() {{add(label);}});
            newIssueFluentCreate.field(Field.PRIORITY, "Minor");
            newIssue = newIssueFluentCreate.execute();

HTML for this field :

<div class="field-group">
   <label for="customfield_1003">Customer<span class="aui-icon icon-required">Required</span></label>
  <select class="select cf-select" id="customfield_1003" multiple="multiple" name="customfield_1003" size="5" data-remove-null-options="true" data-submit-input-val="true" data-input-text="">
            <option value="12306">Text1</option>
            <option value="10615">Text2</option>
            <option value="10329">Text3</option>
            <option value="1225">All</option>
            <option value="11014">Text4</option>
    </select>
</div>

 

0 answers

Suggest an answer

Log in or Sign up to answer