1

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.

2
  • ["val1","val2","val3"] is an array, not a key/value pair. It works if you send it as {"name":"whatever"} because Jira receives it as a key/value pair. Commented May 15, 2016 at 22:37
  • 1
    Try "customfield_10703":(["val1","val2","val3"]).join() instead, this way your custom field will get sent a string instead of an array. Commented May 16, 2016 at 13:53

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.