Reputation: 11
Hi I was wondering if anyone could help me with the following. I am trying to create an issue with a custom field (check boxes) which is an array.
My field in the browser(when I hit http://xxxxxxxx//rest/api/latest/issue/issueId) comes up like this :
"customfield_10703":["val1","val2","val3"],
but when I try to Post it in create Issue I get :
{
"errorMessages": [],
"errors": {
"customfield_10703": "Operation value must be a string"
}
}
I should mention that I have managed to successfully create an issue when I encode it like this
"customfield_10703":"{\"name\": \"Harware setup\"}",
But the problem now is that I cannot create more than one value.
ps. I have already checked administration page and my field is on default screen. Thanks.
Upvotes: 1
Views: 1810
Reputation: 129
Take a look a the "createmeta" for your project. You can retrieve it by making a GET request to <your_jira_server>/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields&projectIds=<project_id>
That should give you more detailed information about the expected format for the data your field. With checkboxes, you'll generally find something like:
"customfield_10600": {
"required": false,
"schema": {
"type": "array",
"items": "option",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes",
"customId": 10600
},
"name": "My Checkbox",
"key": "customfield_10600",
"hasDefaultValue": false,
"operations": [
"add",
"set",
"remove"
],
"allowedValues": [
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10400",
"value": "apples",
"id": "10400"
},
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10401",
"value": "bananas",
"id": "10401"
},
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10402",
"value": "grapes",
"id": "10402"
},
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10403",
"value": "kiwi",
"id": "10403"
},
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10404",
"value": "limes",
"id": "10404"
},
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10405",
"value": "oranges",
"id": "10405"
},
{
"self": "<your_jira_server>/rest/api/2/customFieldOption/10406",
"value": "pears",
"id": "10406"
}
]
}
When you're sending it back to JIRA, it expects an array of option
types. For options, you should be able to use either a {"name": value}
or {"id": id}
JSON object (I've only ever used the ID approach). You should use the value or id from the list of allowed values.
If you want to set more than one, you'll need to send an array of those option objects.
Upvotes: 2