Hi,
I've managed to write a script using API Post to create an issue with all the required fields, but I have a problem with multi select list fields. Whatever I try, these fields remain empty. Can anyone tell me what is wrong with this ?
Here's my script :
def projectKey = 'KESD'
def projectId = get("/rest/api/2/project/${projectKey}").asObject(Map).body.id
String email_resp = "myemail@mydomain.com"
String email_rapp = "hisemail@mydomain.com"
def url_resp = "/rest/api/2/user/picker?query=${email_resp}"
def url_rapp = "/rest/api/2/user/picker?query=${email_rapp}"
def response_resp = get(url_resp).header('Content-Type', 'application/json').asObject(Map)
def accountId_resp = response_resp.body.users.accountId[0]
def response_rapp = get(url_rapp).header('Content-Type', 'application/json').asObject(Map)
def accountId_rapp = response_rapp.body.users.accountId[0]
def ticketType = get("/rest/api/2/issuetype/project?projectId=${projectId}").asObject(List).body.find { it['name'] == 'ServiceRequest' }['id']
post('/rest/api/2/issue')
.header('Content-Type', 'application/json')
.body(
[
fields: [
summary : 'The issue summary',
description: """Hello,
This is the issue description.
Regards,
Me""",
project : [key: projectKey],
issuetype : [id: ticketType],
duedate : "2023-07-17",
reporter : [id: accountId_rapp],
assignee : [id: accountId_resp],
customfield_10138 : "DRIVER",
customfield_10142 : "HOTELS",
customfield_10133 : [{name: 'PARIS'}],
customfield_10143 : [id: "10440"],
customfield_10445 : [{name: 'No Hardware'}],
security : [name:'DSI']
]
])
.asString().body
Everything works fine, except for the customfield_10133 and 10445, which are multi-select list fields with only one value. I tried {id: "<optionId>"}, {name: "<optionValue>"}, {value: "<optionValue>"}, didn't work. I tried with quotes on "id", "name", and "value", I got the " expecting '}', found ':' " error. And if I remove the {} brackets, I get the "value must be in a table" error.
I cannot find the exact syntax for that, all examples on the internet point to other ways to do it with lots of java methods, or Server/Data Center compatible methods.
Thanks for your help.
David
Hi David,
You can set a multi select field using the below syntax:
"customfield_10133": [value: "PARIS"],[value: "BERLIN"]],
I hope this helps!
Lucy
Hi,
As I mentionned in the description, I already tried that, and I get the "Specify the value for xxx in an array" error.
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
In your description you've said you were using brackets {value: "<optionValue>"} but you need to use [] instead [value: "PARIS"].
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lucy,
I did, and I get "Specify the value for xxx in an array" error. I am going to submit a support request from Adaptavist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the answer. The correct syntax is :
customfield_10133 : [[value: "optionvalue"]], so double square brackets around the set of values.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @David Maurel
I found example, that maybe can help you
"customfield_13222" : [{"add" : {"value" : root_cause_value}}]
In similar question it worked
https://community.atlassian.com/t5/Jira-questions/Updating-Multi-Select-Field/qaq-p/898783
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy,
Just tried it, didn't work. Adding the quotes around add and value gets me the " expecting '}', found ':' " error. If I remove the quotes, I don't get the error, but the fields are not populated with my values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.