Unable to update multi-user list using the API

Nick Hassell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2020

I am trying to set a multi-user field using the API - I am running this from the ScriptRunner console, but I don't think this is a ScriptRunner issue.

My code is as follows:

put("/rest/api/3/issue/AB-123")
.header("Content-Type", "application/json")
.body([
fields:[
customfield_11018 : [{id:"<my user id>"}],
assignee: [id: "<my user id>"]
]
])
.asString()

customfield_11018 is a multi-user field, and assignee is a single user field.

When I run this script, there are no errors produced.  The assignee is correctly updated, but the multi-user field is set to blank.

Am I doing something wrong, or is this a bug?

2 answers

2 accepted

1 vote
Answer accepted
Nick Hassell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2020

Thank you.  So the answer is:

put("/rest/api/3/issue/AB-123")
.header("Content-Type", "application/json")
.body([
fields:[
customfield_11018 : [[id:"<my user id>"]],
assignee: [id: "<my user id>"]
]
])
.asString()
0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2020

Hi Nick,

Thank you for your question.

I can confirm that we have an example snippet located here which shows how to set different type of user picker fields with ScriptRunner for Jira Cloud.

Inside this snippet, we show how to set a multi-user picker custom field which requires you to pass an array for each user to be set as a comma-separated list and you can use this example as a reference guide to help you create the script which you require.

I hope this information helps.

Regards,

Kristian

Nick Hassell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2020

Are you able to explain why the documentation says to use curly brackets?:

"customfield_11458" : [ { "name":"inigomontoya" }, { "name":"tommytomtomahawk" }]

See: https://developer.atlassian.com/cloud/jira/service-desk/rest/#fieldformats 

Is this difference to do with ScriptRunner?

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2020

Hi Nick, 

Thank you for confirming that the example which we have provided you have resolved your issue and has allowed you to resolve your issues

I notice that page is from the Jira Service Desk rest API's and is only relevant to Jira Service desk and is not valid for Jira Core or Jira Server projects which are example is based on. 

I would advise contacting Atlassian to check if that example in that documentation link is still valid.

Regards,

Kristian

Nick Hassell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2020

I think that the documentation is correct.  It is because the script is written in Groovy, which substitutes {} for [].  In Groovy, {} is reserved for Closures.

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 29, 2020

Hi Nick,

Thank you for confirming this and for confirming that your issue has been resolved.

Regards,

Kristian

Andrey Permyakov June 1, 2021

@Nick Hassell 

Is there any way to use name?!

customfield_10003 : [["name":"firstname secondname"]] or customfield_10003 : [[name:"firstname secondname"]] - did not work

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 1, 2021

Hi Andrey,

I can confirm that you cannot use a user's name inside of Jira Cloud as Atlassian only allows you to specify users via their accountId since the GDPR changes they made and they enforce this in the rest API's which means you cannot specify users via their username.

Regards,

Kristian

Andrey Permyakov June 1, 2021

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events